- /* Fehler aufgetreten? */
- if(( res != 0 ) || ( err != 0 )) {
- if ( res != 0 )
- Log( LOG_CRIT, "getsockopt (connection %d): %s!", idx, strerror( errno ));
- else
- Log( LOG_CRIT, "Can't connect socket to \"%s:%d\" (connection %d): %s!",
- My_Connections[idx].host, Conf_Server[Conf_GetServer( idx )].port,
- idx, strerror( err ));
-
- /* Clean up socket, connection and client structures */
- c = Client_GetFromConn( idx );
- if( c ) Client_DestroyNow( c );
- io_close( My_Connections[idx].sock );
- Init_Conn_Struct( idx );
-
- /* Bei Server-Verbindungen lasttry-Zeitpunkt auf "jetzt" setzen */
- Conf_Server[Conf_GetServer( idx )].lasttry = time( NULL );
- Conf_UnsetServer( idx );
- return;
+ /* Error while connecting? */
+ if ((res != 0) || (err != 0)) {
+ if (res != 0)
+ Log(LOG_CRIT, "getsockopt (connection %d): %s!",
+ idx, strerror(errno));
+ else
+ Log(LOG_CRIT,
+ "Can't connect socket to \"%s:%d\" (connection %d): %s!",
+ My_Connections[idx].host,
+ 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 = Client_GetFromConn(idx);
+ if (c)
+ Client_DestroyNow(c);
+
+ Conn_Close(idx, "Can't connect!", NULL, false);
+
+ /* Set the timestamp of the last connect attempt */
+ Conf_UnsetServer(idx);
+
+ return;