#include "portab.h"
#include "io.h"
-static char UNUSED id[] = "$Id: conn.c,v 1.198 2006/07/23 23:05:20 alex Exp $";
+static char UNUSED id[] = "$Id: conn.c,v 1.202 2007/01/23 16:07:19 alex Exp $";
#include "imp.h"
#include <assert.h>
{
int res, err;
socklen_t sock_len;
- CLIENT *c;
CONN_ID idx = Socket2Index( sock );
if (idx <= NONE) {
LogDebug("cb_connserver wants to write on unknown socket?!");
Conf_Server[Conf_GetServer(idx)].port,
idx, strerror(err));
- /* Clean up the CLIENT structure (to avoid silly log
- * messages) and call Conn_Close() to do the rest. */
- c = Conn_GetClient(idx);
- if (c)
- Client_DestroyNow(c);
-
- Conn_Close(idx, "Can't connect!", NULL, false);
-
+ Conn_Close(idx, "Can't connect!", NULL, false);
return;
}
Init_Conn_Struct(Pool_Size++);
}
+ /* register callback */
+ if (!io_event_create( new_sock, IO_WANTREAD, cb_clientserver)) {
+ Log(LOG_ALERT, "Can't accept connection: io_event_create failed!");
+ Simple_Message(new_sock, "ERROR :Internal error");
+ close(new_sock);
+ return -1;
+ }
+
c = Client_NewLocal( new_sock, inet_ntoa( new_addr.sin_addr ), CLIENT_UNKNOWN, false );
if( ! c ) {
- Log( LOG_ALERT, "Can't accept connection: can't create client structure!" );
- Simple_Message( new_sock, "ERROR :Internal error" );
- close( new_sock );
+ Log(LOG_ALERT, "Can't accept connection: can't create client structure!");
+ Simple_Message(new_sock, "ERROR :Internal error");
+ io_close(new_sock);
return -1;
}
My_Connections[new_sock].addr = new_addr;
My_Connections[new_sock].client = c;
- /* register callback */
- if (!io_event_create( new_sock, IO_WANTREAD, cb_clientserver)) {
- Simple_Message( new_sock, "ERROR :Internal error" );
- Conn_Close( new_sock, "io_event_create() failed", NULL, false );
- return -1;
- }
-
Log( LOG_INFO, "Accepted connection %d from %s:%d on socket %d.", new_sock,
inet_ntoa( new_addr.sin_addr ), ntohs( new_addr.sin_port), Sock );