diff options
author | Vernon Mauery <vernon.mauery@linux.intel.com> | 2018-11-09 08:43:36 -0800 |
---|---|---|
committer | Vernon Mauery <vernon.mauery@linux.intel.com> | 2019-02-01 13:01:18 -0800 |
commit | 7e4a651799df95e44b4c99825adf18a8ef878f52 (patch) | |
tree | d8ca0552f74bd860f3e0a112cf9eea57e616727b /sd_event_loop.cpp | |
parent | 7a0142c5298b13247614394ea707c1ea0502473d (diff) | |
download | phosphor-net-ipmid-7e4a651799df95e44b4c99825adf18a8ef878f52.tar.gz phosphor-net-ipmid-7e4a651799df95e44b4c99825adf18a8ef878f52.zip |
netipmid: move sol console sockets to asio
Rewrite the SOL console sockets use boost::asio. This reduces code size
and ties better into the main asio io loop.
Change-Id: Ia79b9aa3fa3c7ce1ddd9b609b032160a88394f8c
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
Diffstat (limited to 'sd_event_loop.cpp')
-rw-r--r-- | sd_event_loop.cpp | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/sd_event_loop.cpp b/sd_event_loop.cpp index 990426f..8d24d23 100644 --- a/sd_event_loop.cpp +++ b/sd_event_loop.cpp @@ -61,50 +61,6 @@ void EventLoop::startRmcpReceive() }); } -static int consoleInputHandler(sd_event_source* es, int fd, uint32_t revents, - void* userdata) -{ - try - { - int readSize = 0; - - if (ioctl(fd, FIONREAD, &readSize) < 0) - { - log<level::ERR>("ioctl failed for FIONREAD:", - entry("ERRNO=%d", errno)); - return 0; - } - - std::vector<uint8_t> buffer(readSize); - auto bufferSize = buffer.size(); - ssize_t readDataLen = 0; - - readDataLen = read(fd, buffer.data(), bufferSize); - - // Update the Console buffer with data read from the socket - if (readDataLen > 0) - { - buffer.resize(readDataLen); - std::get<sol::Manager&>(singletonPool).dataBuffer.write(buffer); - } - else if (readDataLen == 0) - { - log<level::ERR>("Connection Closed for host console socket"); - } - else if (readDataLen < 0) // Error - { - log<level::ERR>("Reading from host console socket failed:", - entry("ERRNO=%d", errno)); - } - } - catch (std::exception& e) - { - log<level::ERR>(e.what()); - } - - return 0; -} - static int charAccTimerHandler(sd_event_source* s, uint64_t usec, void* userdata) { @@ -223,45 +179,6 @@ int EventLoop::startEventLoop() return EXIT_SUCCESS; } -void EventLoop::startHostConsole(const sol::CustomFD& fd) -{ - int rc = 0; - - if ((fd() == -1) || hostConsole.get()) - { - throw std::runtime_error("Console descriptor already added"); - } - - sd_event_source* source = nullptr; - - // Add the fd to the event loop for EPOLLIN - rc = sd_event_add_io(event, &source, fd(), EPOLLIN, consoleInputHandler, - nullptr); - if (rc < 0) - { - throw std::runtime_error("Failed to add socket descriptor"); - } - - hostConsole.reset(source); - source = nullptr; -} - -void EventLoop::stopHostConsole() -{ - if (hostConsole.get()) - { - // Disable the host console payload - int rc = sd_event_source_set_enabled(hostConsole.get(), SD_EVENT_OFF); - if (rc < 0) - { - log<level::ERR>("Failed to disable the host console socket", - entry("RC=%d", rc)); - } - - hostConsole.reset(); - } -} - void EventLoop::startSOLPayloadInstance(uint8_t payloadInst, IntervalType accumulateInterval, IntervalType retryInterval) |