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;
IO_WANTREAD);
continue;
}
+
io_event_add(My_Connections[i].sock, IO_WANTREAD);
}
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 );
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 */
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 */
* IDENT user name.*/
CLIENT *c;
- int i;
+ CONN_ID i;
size_t len;
char *identptr;
#ifdef IDENTAUTH
#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 );
}
/* 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;
}
+/**
+ * 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
/**