|
a/src/netcon.cpp |
|
b/src/netcon.cpp |
|
... |
|
... |
49 |
#include <vector>
|
49 |
#include <vector>
|
50 |
#endif
|
50 |
#endif
|
51 |
|
51 |
|
52 |
#include <map>
|
52 |
#include <map>
|
53 |
|
53 |
|
|
|
54 |
#ifdef MDU_INCLUDE_LOG
|
|
|
55 |
#include MDU_INCLUDE_LOG
|
|
|
56 |
#else
|
54 |
#include "log.h"
|
57 |
#include "log.h"
|
|
|
58 |
#endif
|
55 |
|
59 |
|
56 |
using namespace std;
|
60 |
using namespace std;
|
57 |
|
61 |
|
58 |
#ifndef SOCKLEN_T
|
62 |
#ifndef SOCKLEN_T
|
59 |
#define SOCKLEN_T socklen_t
|
63 |
#define SOCKLEN_T socklen_t
|
|
... |
|
... |
420 |
struct timespec ts;
|
424 |
struct timespec ts;
|
421 |
m->periodictimeout(&ts);
|
425 |
m->periodictimeout(&ts);
|
422 |
// Wait for something to happen
|
426 |
// Wait for something to happen
|
423 |
vector<struct kevent> events;
|
427 |
vector<struct kevent> events;
|
424 |
events.resize(nfds);
|
428 |
events.resize(nfds);
|
425 |
LOGDEB("Netcon::selectloop: kevent(), nfds = " << nfds << "\n");
|
429 |
LOGDEB1("Netcon::selectloop: kevent(), nfds = " << nfds << "\n");
|
426 |
int ret = kevent(m->kq, 0, 0, &events[0], events.size(), &ts);
|
430 |
int ret = kevent(m->kq, 0, 0, &events[0], events.size(), &ts);
|
427 |
LOGDEB("Netcon::selectloop: nfds " << nfds <<
|
431 |
LOGDEB1("Netcon::selectloop: nfds " << nfds <<
|
428 |
" kevent returns " << ret << "\n");
|
432 |
" kevent returns " << ret << "\n");
|
429 |
if (ret < 0) {
|
433 |
if (ret < 0) {
|
430 |
LOGSYSERR("Netcon::selectloop", "kevent", "");
|
434 |
LOGSYSERR("Netcon::selectloop", "kevent", "");
|
431 |
return -1;
|
435 |
return -1;
|
432 |
}
|
436 |
}
|
|
... |
|
... |
447 |
return -1;
|
451 |
return -1;
|
448 |
}
|
452 |
}
|
449 |
int canread = ev.filter == EVFILT_READ;
|
453 |
int canread = ev.filter == EVFILT_READ;
|
450 |
int canwrite = ev.filter == EVFILT_WRITE;
|
454 |
int canwrite = ev.filter == EVFILT_WRITE;
|
451 |
bool none = !canread && !canwrite;
|
455 |
bool none = !canread && !canwrite;
|
452 |
LOGDEB("Netcon::selectloop: fd " << int(ev.ident) << " " <<
|
456 |
LOGDEB1("Netcon::selectloop: fd " << int(ev.ident) << " " <<
|
453 |
(none ? "blocked" : "can") << " " <<
|
457 |
(none ? "blocked" : "can") << " " <<
|
454 |
(canread ? "read" : "") << " " <<
|
458 |
(canread ? "read" : "") << " " <<
|
455 |
(canwrite ? "write" : "") << "\n");
|
459 |
(canwrite ? "write" : "") << "\n");
|
456 |
if (none) {
|
460 |
if (none) {
|
457 |
LOGERR("Kevent returned unknown filter " << ev.filter <<endl);
|
461 |
LOGERR("Kevent returned unknown filter " << ev.filter <<endl);
|