Explorar o código

* Fixed server connects not working after failing.
* Fixed an invalid killsock() call


svn: 775

Bryan Drewery %!s(int64=22) %!d(string=hai) anos
pai
achega
45ce46eb49
Modificáronse 3 ficheiros con 12 adicións e 14 borrados
  1. 1 0
      doc/UPDATES
  2. 11 12
      src/mod/server.mod/servmsg.c
  3. 0 2
      src/net.c

+ 1 - 0
doc/UPDATES

@@ -10,6 +10,7 @@ This is a summary of ChangeLog basically.
 7.Fixed a segfault in cmd_chaddr (ipv6 ips still not supported)
 8.Changed format for ADDRESS display again.
 9.Fixed dcc cmdpasses.
+10.Fixed the annoying 'attempt to kill unallocated socket' log when a device is broken.
 
 1.1.1
 1.Fixed a problem with using /DCC CHAT <bot>

+ 11 - 12
src/mod/server.mod/servmsg.c

@@ -907,12 +907,12 @@ static int gotmode(char *from, char *msg)
 
 static void disconnect_server(int idx, int dolost)
 {
-  server_online = 0;
   if (dcc[idx].sock >= 0)
     killsock(dcc[idx].sock);
   dcc[idx].sock = -1;
   serv = -1;
   servidx = -1;
+  server_online = 0;
   botuserhost[0] = 0;
   if (dolost) {
     trying_server = 0;
@@ -1238,13 +1238,9 @@ static void connect_server(void)
 
 static void server_resolve_failure(int idx)
 {
-/* FIXME, server_trying = 0???? */
-  serv = -1;
-  /* servidx = -1; */
   resolvserv = 0;
   putlog(LOG_SERV, "*", "%s %s (%s)", IRC_FAILEDCONNECT, dcc[idx].host, IRC_DNSFAILED);
-  lostdcc(idx);
-
+  disconnect_server(idx, DO_LOST);
 }
 
 static void server_resolve_success(int idx)
@@ -1261,18 +1257,21 @@ static void server_resolve_success(int idx)
 #else
   serv = open_telnet(iptostr(htonl(dcc[idx].addr)), dcc[idx].port);
 #endif /* USE_IPV6 */
+
+  /* set these now so if we fail disconnect_server() can cleanup right. */
+  dcc[idx].sock = serv;
+  servidx = idx;
+
   if (serv < 0) {
     neterror(s);
-/* FIXME server_trying = 0?? */
+
     putlog(LOG_SERV, "*", "%s %s (%s)", IRC_FAILEDCONNECT, dcc[idx].host, s);
-    lostdcc(idx);
-    /* servidx = -1; */
+    disconnect_server(idx, DO_LOST);
+
     if (oldserv == curserv && !never_give_up)
       fatal("NO SERVERS WILL ACCEPT MY CONNECTION.", 0);
-  } else {
-    dcc[idx].sock = serv;
 
-    servidx = idx; 		/* not sure about this, servidx serves as current server idx.. sooo... ? */
+  } else {
 
 #ifdef HAVE_SSL
     if (!ssl_link(dcc[idx].sock, CONNECT_SSL)) {

+ 0 - 2
src/net.c

@@ -717,8 +717,6 @@ int open_telnet(char *server, int port)
   int sock = getsock(0) , ret = open_telnet_raw(sock, server, port);
 #endif /* USE_IPV6 */
 
-  if (ret < 0)
-    killsock(sock);
   return ret;
 }