From 38ac577c2151d8ce96a933c68b36e33d3c18c6e7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net>
Date: Tue, 19 May 1998 13:35:39 -0700
Subject: [PATCH] flock fix + more debug

Rev: src/modules/files/file.c:1.97
Rev: src/modules/files/file_functions.h:1.2
---
 src/modules/files/file.c           | 24 +++++++++++++++++++++---
 src/modules/files/file_functions.h |  5 +++++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/src/modules/files/file.c b/src/modules/files/file.c
index 7768067465..20baa6b0c6 100644
--- a/src/modules/files/file.c
+++ b/src/modules/files/file.c
@@ -5,7 +5,7 @@
 \*/
 
 #include "global.h"
-RCSID("$Id: file.c,v 1.96 1998/05/12 16:26:40 grubba Exp $");
+RCSID("$Id: file.c,v 1.97 1998/05/19 20:35:39 hubbe Exp $");
 #include "fdlib.h"
 #include "interpret.h"
 #include "svalue.h"
@@ -2055,8 +2055,6 @@ static void init_file_locking(void)
   set_exit_callback(exit_file_lock_key);
   file_lock_key_program=end_program();
   file_lock_key_program->flags |= PROGRAM_DESTRUCT_IMMEDIATE;
-  add_function("lock",file_lock,"function(void|int:object)",0);
-  add_function("trylock",file_trylock,"function(void|int:object)",0);
 }
 static void exit_file_locking(void)
 {
@@ -2108,6 +2106,20 @@ void PIKE_CONCAT(Y,_ref) (INT32 args) {\
 
 #include "file_functions.h"
 
+#ifdef DEBUG
+void check_static_file_data(struct callback *a, void *b, void *c)
+{
+  if(file_program)
+  {
+#define FILE_FUNC(X,Y,Z) \
+    if(PIKE_CONCAT(Y,_function_number)<0 || PIKE_CONCAT(Y,_function_number)>file_program->num_identifier_references) \
+      fatal(#Y "_function_number is incorrect: %d\n",PIKE_CONCAT(Y,_function_number));
+#include "file_functions.h"
+  }
+}
+#endif
+
+
 void pike_module_init(void)
 {
   struct object *o;
@@ -2174,6 +2186,12 @@ void pike_module_init(void)
 #ifdef HAVE_OOB
   add_integer_constant("__HAVE_OOB__",1,0);
 #endif
+#ifdef DEBUG
+  add_to_callback(&do_debug_callbacks,
+		  check_static_file_data,
+		  0,
+		  0);
+#endif
 }
 
 /* Used from backend */
diff --git a/src/modules/files/file_functions.h b/src/modules/files/file_functions.h
index 9da0e484ec..4242dc51ee 100644
--- a/src/modules/files/file_functions.h
+++ b/src/modules/files/file_functions.h
@@ -44,4 +44,9 @@
   FILE_FUNC("proxy",file_proxy,"function(object:void)")
 #endif
 
+#ifdef HAVE_FD_FLOCK
+  FILE_FUNC("lock",file_lock,"function(void|int:object)")
+  FILE_FUNC("trylock",file_trylock,"function(void|int:object)")
+#endif
+
 #undef FILE_FUNC
-- 
GitLab