150{
151
152 fd_set fdset;
153
154
155 int nfd;
156 for (;;) {
157 FD_ZERO(&fdset);
158 int highest = 0;
159 if (m_iopipe[0] > 0) {
160 FD_SET(m_iopipe[0], &fdset);
161 highest = m_iopipe[0];
162 } else {
163 printf("Pipe for log is not availablle\n");
164 }
165 NSMcontext* nsmc = RFNSM::GetContext();
166 if (nsmc) {
167 if (nsmc->sock > highest) highest = nsmc->sock;
168 FD_SET(nsmc->sock, &fdset);
169 } else {
170
171 }
172
173 struct timeval tv;
174 tv.tv_sec = 1;
175 tv.tv_usec = 1;
176
177 if ((nfd = select(highest + 1, &fdset, NULL, NULL, &tv)) < 0) {
178 switch (errno) {
179 case EINTR: continue;
180 case EAGAIN: continue;
181 default:
182
183
184 return 0;
185 }
186 } else {
187 if (nsmc && FD_ISSET(nsmc->sock, &fdset)) {
188
189 char buf[NSM_TCPMSGSIZ];
190 if (nsmlib_recv(nsmc, reinterpret_cast<struct NSMtcphead_struct*>(buf), 1000) < 0)
191 printf("RFProcessManager: Failed to read NSM context\n");
192 else
193 nsmlib_call(nsmc, reinterpret_cast<struct NSMtcphead_struct*>(buf));
194 }
195 if (m_iopipe[0] > 0 &&
196 FD_ISSET(m_iopipe[0], &fdset)) {
197 break;
198 }
199 if (nfd == 0) break;
200 }
201 }
202
203
204
205
206 return nfd;
207}