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