comparison listener.c @ 13:db2c8e6fb284

Fixed stupid agentfwd error (using the listening FD, not the accepted on. gah)
author Matt Johnston <matt@ucc.asn.au>
date Thu, 03 Jun 2004 18:08:34 +0000
parents 7f77962de998
children 20563735e8b5
comparison
equal deleted inserted replaced
12:7a37cff27258 13:db2c8e6fb284
1 #include "includes.h" 1 #include "includes.h"
2 #include "listener.h" 2 #include "listener.h"
3 #include "session.h" 3 #include "session.h"
4 #include "dbutil.h" 4 #include "dbutil.h"
5 5
6 void listener_initialise() { 6 void listeners_initialise() {
7 7
8 /* just one slot to start with */ 8 /* just one slot to start with */
9 ses.listeners = (struct Listener**)m_malloc(sizeof(struct Listener*)); 9 ses.listeners = (struct Listener**)m_malloc(sizeof(struct Listener*));
10 ses.listensize = 1; 10 ses.listensize = 1;
11 ses.listeners[0] = NULL; 11 ses.listeners[0] = NULL;
19 19
20 /* check each in turn */ 20 /* check each in turn */
21 for (i = 0; i < ses.listensize; i++) { 21 for (i = 0; i < ses.listensize; i++) {
22 listener = ses.listeners[i]; 22 listener = ses.listeners[i];
23 if (listener != NULL) { 23 if (listener != NULL) {
24 TRACE(("set listener fd %d", listener->sock));
24 FD_SET(listener->sock, readfds); 25 FD_SET(listener->sock, readfds);
25 } 26 }
26 } 27 }
27 } 28 }
28 29
34 35
35 /* check each in turn */ 36 /* check each in turn */
36 for (i = 0; i < ses.listensize; i++) { 37 for (i = 0; i < ses.listensize; i++) {
37 listener = ses.listeners[i]; 38 listener = ses.listeners[i];
38 if (listener != NULL) { 39 if (listener != NULL) {
40 TRACE(("handle listener num %d fd %d", i, listener->sock));
39 if (FD_ISSET(listener->sock, readfds)) { 41 if (FD_ISSET(listener->sock, readfds)) {
40 listener->accepter(listener); 42 listener->accepter(listener);
41 } 43 }
42 } 44 }
43 } 45 }
78 } 80 }
79 } 81 }
80 82
81 ses.maxfd = MAX(ses.maxfd, sock); 83 ses.maxfd = MAX(ses.maxfd, sock);
82 84
85 TRACE(("new listener num %d fd %d", i, sock));
86
83 newlisten = (struct Listener*)m_malloc(sizeof(struct Listener)); 87 newlisten = (struct Listener*)m_malloc(sizeof(struct Listener));
84 newlisten->index = i; 88 newlisten->index = i;
85 newlisten->type = type; 89 newlisten->type = type;
86 newlisten->typedata = typedata; 90 newlisten->typedata = typedata;
87 newlisten->sock = sock; 91 newlisten->sock = sock;