diff options
| author | Anton <anton@picapica> | 2016-09-25 01:14:51 +0400 |
|---|---|---|
| committer | Anton <anton@picapica> | 2016-09-25 01:14:51 +0400 |
| commit | fbe88d4debb49d03a3a97e450ca2a69bf91b058b (patch) | |
| tree | d84f56a6eff80f9db801ea8562b5b14227f1f957 | |
| parent | 076f242539c57cc4f3ccec388c0f09403aa43227 (diff) | |
| download | pica-pica-fbe88d4debb49d03a3a97e450ca2a69bf91b058b.tar.gz pica-pica-fbe88d4debb49d03a3a97e450ca2a69bf91b058b.zip | |
linked listener processing to c2n struct
| -rw-r--r-- | PICA_client.c | 38 | ||||
| -rw-r--r-- | PICA_client.h | 2 | ||||
| -rw-r--r-- | pica-client/skynet.cpp | 2 |
3 files changed, 15 insertions, 27 deletions
diff --git a/PICA_client.c b/PICA_client.c index 63ed3eb..b1ff144 100644 --- a/PICA_client.c +++ b/PICA_client.c @@ -1904,13 +1904,12 @@ static void fdset_add(fd_set *fds, int fd, int *max) *max = fd; } -int PICA_event_loop(struct PICA_c2n **connections, struct PICA_listener **listeners, int timeout) +int PICA_event_loop(struct PICA_c2n **connections, int timeout) { fd_set rfds, wfds; struct timeval tv; int ret, nfds = 0; struct PICA_c2n **ic2n; - struct PICA_listener **ilst; //puts("PICA_event_loop");//debug @@ -1920,14 +1919,6 @@ int PICA_event_loop(struct PICA_c2n **connections, struct PICA_listener **listen FD_ZERO(&rfds); FD_ZERO(&wfds); - ilst = listeners; - - while(ilst && *ilst) - { - fdset_add(&rfds, (*ilst)->sck_listener, &nfds); - ilst++; - } - ic2n = connections; while(ic2n && *ic2n) @@ -1942,6 +1933,8 @@ int PICA_event_loop(struct PICA_c2n **connections, struct PICA_listener **listen || (*ic2n)->state == PICA_C2N_STATE_WAITINGTLS) fdset_add(&wfds, (*ic2n)->sck_comm, &nfds); + fdset_add(&rfds, (*ic2n)->directc2c_listener->sck_listener, &nfds); + ic2c = (*ic2n)->chan_list_head; while(ic2c) @@ -1980,21 +1973,6 @@ int PICA_event_loop(struct PICA_c2n **connections, struct PICA_listener **listen //processing listeners, c2n and c2c connections - ilst = listeners; - - while(ilst && *ilst) - { - ret = process_listener(*ilst, &rfds); - - if (ret != PICA_OK) - { - callbacks.listener_error_cb(*ilst, ret); - PICA_close_listener(*ilst); - } - - ilst++; - } - ic2n = connections; while(ic2n && *ic2n) @@ -2018,6 +1996,16 @@ int PICA_event_loop(struct PICA_c2n **connections, struct PICA_listener **listen { struct PICA_c2c *kill_ptr = 0; + //processing listener associated with current c2n + ret = process_listener((*ic2n)->directc2c_listener, &rfds); + + if (ret != PICA_OK) + { + callbacks.listener_error_cb((*ic2n)->directc2c_listener, ret); + PICA_close_listener((*ic2n)->directc2c_listener); + } + + ic2c = (*ic2n)->chan_list_head; //processing c2c connections associated with current c2n diff --git a/PICA_client.h b/PICA_client.h index ad13740..30f9cf9 100644 --- a/PICA_client.h +++ b/PICA_client.h @@ -313,7 +313,7 @@ int PICA_open_acc(const char *cert_file, //connections, listeners - NULL-terminated arrays of pointers to appropriate structures // timeout - timeout in milliseconds -int PICA_event_loop(struct PICA_c2n **connections, struct PICA_listener **listeners, int timeout); +int PICA_event_loop(struct PICA_c2n **connections, int timeout); int PICA_send_msg(struct PICA_c2c *chn, char *buf, unsigned int len); diff --git a/pica-client/skynet.cpp b/pica-client/skynet.cpp index acb0fef..7388634 100644 --- a/pica-client/skynet.cpp +++ b/pica-client/skynet.cpp @@ -246,7 +246,7 @@ void SkyNet::timerEvent(QTimerEvent *e) nodelinks.append(NULL); - ret = PICA_event_loop(nodelinks.data(), NULL, 1); + ret = PICA_event_loop(nodelinks.data(), 1); if (ret != PICA_OK) emit StatusMsg("event loop error!", true);//show some error message |
