X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fconn.c;h=f4efff1655002f5687b44b8beb9f9cb38c90fbf2;hp=dff9336f65af4c2f7e581185d1396047e7b5d92b;hb=bf8b64630443b2bd3fe2a298f860ea0d492df649;hpb=60f5dd5b29e701b3ab601addd3cdefb508acc7d1 diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index dff9336f..f4efff16 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -68,7 +68,6 @@ #include "log.h" #include "ng_ipaddr.h" #include "parse.h" -#include "proc.h" #include "resolve.h" #include "tool.h" @@ -1382,11 +1381,6 @@ New_Connection(int Sock) Resolve_Addr(&My_Connections[new_sock].proc_stat, &new_addr, identsock, cb_Read_Resolver_Result); - /* ngIRCd waits up to 4 seconds for the result of the asynchronous - * DNS and IDENT resolver subprocess using the "penalty" mechanism. - * If there are results earlier, the delay is aborted. */ - Conn_SetPenalty(new_sock, 4); - Account_Connection(); return new_sock; } /* New_Connection */ @@ -1991,7 +1985,7 @@ cb_Read_Resolver_Result( int r_fd, UNUSED short events ) * IDENT user name.*/ CLIENT *c; - int i; + CONN_ID i; size_t len; char *identptr; #ifdef IDENTAUTH @@ -2001,14 +1995,8 @@ cb_Read_Resolver_Result( int r_fd, UNUSED short events ) #endif LogDebug("Resolver: Got callback on fd %d, events %d", r_fd, events ); - - /* Search associated connection ... */ - for( i = 0; i < Pool_Size; i++ ) { - if(( My_Connections[i].sock != NONE ) - && (Proc_GetPipeFd(&My_Connections[i].proc_stat) == r_fd)) - break; - } - if( i >= Pool_Size ) { + i = Conn_GetFromProc(r_fd); + if (i == NONE) { /* Ops, none found? Probably the connection has already * been closed!? We'll ignore that ... */ io_close( r_fd ); @@ -2060,8 +2048,6 @@ cb_Read_Resolver_Result( int r_fd, UNUSED short events ) #ifdef DEBUG else Log( LOG_DEBUG, "Resolver: discarding result for already registered connection %d.", i ); #endif - /* Reset penalty time */ - Conn_ResetPenalty( i ); } /* cb_Read_Resolver_Result */ @@ -2112,6 +2098,42 @@ Conn_GetClient( CONN_ID Idx ) return c ? c->client : NULL; } +/** + * Get PROC_STAT sub-process structure of a connection. + * @param Idx Connection index number + * @return PROC_STAT structure + */ +GLOBAL PROC_STAT * +Conn_GetProcStat(CONN_ID Idx) +{ + CONNECTION *c; + + assert(Idx >= 0); + c = array_get(&My_ConnArray, sizeof (CONNECTION), (size_t)Idx); + assert(c != NULL); + return &c->proc_stat; +} /* Conn_GetProcStat */ + + +/** + * Get CONN_ID from file descriptor associated to a subprocess structure. + * @param fd File descriptor + * @return CONN_ID or NONE (-1) + */ +GLOBAL CONN_ID +Conn_GetFromProc(int fd) +{ + int i; + + assert(fd > 0); + for (i = 0; i < Pool_Size; i++) { + if ((My_Connections[i].sock != NONE) + && (Proc_GetPipeFd(&My_Connections[i].proc_stat) == fd)) + return i; + } + return NONE; +} /* Conn_GetFromProc */ + #ifdef SSL_SUPPORT