X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Fconn.c;h=4df1e9e4f88e644b3df309f5bb1007c2aee44be3;hb=3d49fa5bffac43f2fcf535c8b1aedae732d1f9f5;hp=495c54f1d81a34ec00505ad7695f56ca369b3bf5;hpb=54e67ea9ee6c2b00c43f759edc55b57b969c9e2d;p=ngircd-alex.git diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index 495c54f1..4df1e9e4 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -755,8 +755,9 @@ Conn_Handler(void) if (SSL_WantWrite(&My_Connections[i])) continue; /* TLS/SSL layer needs to write data; deal with this first */ #endif - if (Proc_InProgress(&My_Connections[i].res_stat)) { - /* Wait for completion of resolver sub-process ... */ + if (Proc_InProgress(&My_Connections[i].proc_stat)) { + /* Wait for completion of forked subprocess + * and ignore the socket in the meantime ... */ io_event_del(My_Connections[i].sock, IO_WANTREAD); continue; @@ -772,6 +773,7 @@ Conn_Handler(void) IO_WANTREAD); continue; } + io_event_add(My_Connections[i].sock, IO_WANTREAD); } @@ -1073,9 +1075,9 @@ Conn_Close( CONN_ID Idx, const char *LogMsg, const char *FwdMsg, bool InformClie in_k, out_k); } - /* cancel running resolver */ - if (Proc_InProgress(&My_Connections[Idx].res_stat)) - Proc_Kill(&My_Connections[Idx].res_stat); + /* Kill possibly running subprocess */ + if (Proc_InProgress(&My_Connections[Idx].proc_stat)) + Proc_Kill(&My_Connections[Idx].proc_stat); /* Servers: Modify time of next connect attempt? */ Conf_UnsetServer( Idx ); @@ -1377,14 +1379,9 @@ New_Connection(int Sock) identsock = -1; #endif if (!Conf_NoDNS) - Resolve_Addr(&My_Connections[new_sock].res_stat, &new_addr, + 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 */ @@ -1889,7 +1886,7 @@ Init_Conn_Struct(CONN_ID Idx) My_Connections[Idx].signon = now; My_Connections[Idx].lastdata = now; My_Connections[Idx].lastprivmsg = now; - Proc_InitStruct(&My_Connections[Idx].res_stat); + Proc_InitStruct(&My_Connections[Idx].proc_stat); } /* Init_Conn_Struct */ @@ -1989,7 +1986,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 @@ -1999,14 +1996,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].res_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 ); @@ -2015,7 +2006,7 @@ cb_Read_Resolver_Result( int r_fd, UNUSED short events ) } /* Read result from pipe */ - len = Resolve_Read(&My_Connections[i].res_stat, readbuf, sizeof readbuf -1); + len = Resolve_Read(&My_Connections[i].proc_stat, readbuf, sizeof readbuf -1); if (len == 0) return; @@ -2111,6 +2102,26 @@ Conn_GetClient( CONN_ID Idx ) } +/** + * 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 /**