Преглед на файлове

Added a leet killsock() function

svn: 114
Bryan Drewery преди 23 години
родител
ревизия
b0d83272fc
променени са 5 файла, в които са добавени 21 реда и са изтрити 5 реда
  1. 1 0
      src/eggdrop.h
  2. 2 1
      src/mod/module.h
  3. 15 1
      src/modules.c
  4. 2 2
      src/net.c
  5. 1 1
      src/proto.h

+ 1 - 0
src/eggdrop.h

@@ -205,6 +205,7 @@ typedef int socklen_t;
 #define nmalloc(x)	n_malloc((x),__FILE__,__LINE__)
 #define nrealloc(x,y)	n_realloc((x),(y),__FILE__,__LINE__)
 #define nfree(x)	n_free((x),__FILE__,__LINE__)
+#define killsock(x)	real_killsock((x),__FILE__,__LINE__)
 
 #ifdef DEBUG_CONTEXT
 #  define Context		eggContext(__FILE__, __LINE__, NULL)

+ 2 - 1
src/mod/module.h

@@ -42,6 +42,7 @@
  * held responsible for mental break-downs caused by this file <G>
  */
 
+#undef killsock
 #undef nmalloc
 #undef nfree
 #undef nrealloc
@@ -203,7 +204,7 @@
 #else
 #define getsock ((int (*) (int))global[82])
 #endif /* USE_IPV6 */
-#define killsock ((void (*) (int))global[83])
+#define killsock(x) (((void *(*)())global[83])((x),MODULE_NAME,__FILE__,__LINE__))
 /* 84 - 87 */
 #define open_listen ((int (*) (int *))global[84])
 #define open_telnet_dcc ((int (*) (int,char *,char *))global[85])

+ 15 - 1
src/modules.c

@@ -64,6 +64,20 @@ void check_static(char *name, char *(*func) ())
   static_modules = p;
 }
 
+void *mod_killsock(int size, const char *modname, const char *filename, int line)
+{
+#ifdef DEBUG_MEM
+  char x[100], *p;
+
+  p = strrchr(filename, '/');
+  egg_snprintf(x, sizeof x, "%s:%s", modname, p ? p + 1 : filename);
+  x[19] = 0;
+  real_killsock(size, x, line);
+#else
+  killsock(size);
+#endif
+  return NULL;
+}
 
 
 /* The null functions */
@@ -240,7 +254,7 @@ Function global_table[] =
   (Function) new_dcc,
   (Function) lostdcc,
   (Function) getsock,
-  (Function) killsock,
+  (Function) mod_killsock,
   /* 84 - 87 */
   (Function) open_listen,
   (Function) open_telnet_dcc,

+ 2 - 2
src/net.c

@@ -393,7 +393,7 @@ int getsock(int options)
 
 /* Done with a socket
  */
-void killsock(register int sock)
+void real_killsock(register int sock, const char *file, int line)
 {
   register int	i;
 
@@ -417,7 +417,7 @@ void killsock(register int sock)
       return;
     }
   }
-  putlog(LOG_MISC, "*", "Attempt to kill un-allocated socket %d !!", sock);
+  putlog(LOG_MISC, "*", "Attempt to kill un-allocated socket %d %s:%d !!", sock, file, line);
 }
 
 /* Send connection request to proxy

+ 1 - 1
src/proto.h

@@ -296,7 +296,7 @@ int getsock(int);
 #endif /* USE_IPV6 */
 int getprotocol(char *);
 char *hostnamefromip(unsigned long);
-void killsock(int);
+void real_killsock(int, const char *, int);
 int answer(int, char *, unsigned long *, unsigned short *, int);
 inline int open_listen(int *);
 #ifdef USE_IPV6