Hi,

flip phillips wrote:

> Almost!
> It compiles but fails when run - PANIC: Error while
> pthread_rwlock_rdlock
> Seems related?

that's very very bad :( I have fixed cvs to catch init errors too, please
get it a try (I would like to know if already init fail and wich error we
got)... I don't know, what's wrong?

P.S. Attached you can find a patch that possible fixes this issue, but I'm
unsure. Please apply it and report if it works for you...


> 
> [ebv.skidmore.edu] % bearerbox ./doc/examples/kannel.conf
> 2004-08-08 19:52:59 [15626] [0] INFO: Debug_lvl = -1, log_file =
> <none>, log_lvl = 0
> 2004-08-08 19:52:59 [15626] [0] WARNING: DLR: using default 'internal'
> for storage type.
> 2004-08-08 19:52:59 [15626] [0] INFO: DLR using storage type: internal
> 2004-08-08 19:52:59 [15626] [0] DEBUG: Kannel bearerbox version
> `cvs-20040808'.
> Build `Aug  8 2004 19:51:12', compiler `3.3 20030304 (Apple Computer,
> Inc. build 1435)'.
> System Darwin, release 7.4.0, version Darwin Kernel Version 7.4.0: Wed
> May 12 16:58:24 PDT 2004; root:xnu/xnu-517.7.7.obj~7/RELEASE_PPC ,
> machine Power Macintosh.
> Hostname ebv.skidmore.edu, IP 141.222.88.130.
> Libxml version 2.5.4.
> Using native malloc.
> 
> 2004-08-08 19:52:59 [15626] [0] INFO: SSL not supported, no SSL
> initialization done.
> 2004-08-08 19:52:59 [15626] [0] INFO: HTTP: Opening server at port
> 13000.
> 2004-08-08 19:52:59 [15626] [0] DEBUG: Started thread 1
> (gwlib/fdset.c:poller)
> 2004-08-08 19:52:59 [15626] [1] DEBUG: Thread 1 (gwlib/fdset.c:poller)
> maps to pid 15626.
> 2004-08-08 19:52:59 [15626] [0] DEBUG: Started thread 2
> (gwlib/http.c:server_thread)
> 2004-08-08 19:52:59 [15626] [2] DEBUG: Thread 2
> (gwlib/http.c:server_thread) maps to pid 15626.
> 2004-08-08 19:52:59 [15626] [0] DEBUG: Started thread 3
> (gw/bb_http.c:httpadmin_run)
> 2004-08-08 19:53:00 [15626] [3] DEBUG: Thread 3
> (gw/bb_http.c:httpadmin_run) maps to pid 15626.
> 2004-08-08 19:53:00 [15626] [0] INFO:
> ----------------------------------------
> 2004-08-08 19:53:00 [15626] [0] INFO: Kannel bearerbox II version
> cvs-20040808 starting
> 2004-08-08 19:53:05 [15626] [0] INFO: MAIN: Start-up done, entering
> mainloop
> 2004-08-08 19:53:05 [15626] [0] PANIC: Error while
> pthread_rwlock_rdlock.
> 2004-08-08 19:53:05 [15626] [0] PANIC: System error 22: Invalid argument
> 
> On Aug 8, 2004, at 4:39 PM, [EMAIL PROTECTED] wrote:
> 
>>
>> Hi,
>>
>> indeed it's a bug :( I have fixed this in cvs, please get it a try...
>>
>> P.S. from:
>> http://www.opengroup.org/onlinepubs/009695399/basedefs/pthread.h.html
>> (PTHREAD_RWLOCK_INITIALIZER is deleted for alignment with IEEE Std
>> 1003.1j-2000)
>>

-- 
Thanks,
Alex
Index: gwlib/gw-rwlock.c
===================================================================
RCS file: /home/cvs/gateway/gwlib/gw-rwlock.c,v
retrieving revision 1.3
diff -a -u -p -r1.3 gw-rwlock.c
--- gwlib/gw-rwlock.c	9 Aug 2004 09:06:22 -0000	1.3
+++ gwlib/gw-rwlock.c	9 Aug 2004 09:17:33 -0000
@@ -68,11 +68,20 @@
 
 RWLock *gw_rwlock_create(void)
 {
+    pthread_rwlockattr_t attr;
     RWLock *ret = gw_malloc(sizeof(*ret));
-    int rc = pthread_rwlock_init(&ret->rwlock, NULL);
+    int rc;
+
+    rc = pthread_rwlockattr_init(&attr);
+    if (rc != 0)
+        panic(rc, "Initialization of pthread_rwlockattr_t failed.");
+    rc = pthread_rwlock_init(&ret->rwlock, &attr);
     if (rc != 0)
         panic(rc, "Initialization of RWLock failed.");
     ret->dynamic = 1;
+    rc = pthread_rwlockattr_destroy(&attr);
+    if (rc != 0)
+        error(rc, "Could not destroy pthread_rwlockattr_t.");
 
     return ret;
 }
@@ -80,10 +89,19 @@ RWLock *gw_rwlock_create(void)
 
 void gw_rwlock_init_static(RWLock *lock)
 {
-    int rc = pthread_rwlock_init(&lock->rwlock, NULL);
+    pthread_rwlockattr_t attr;
+    int rc;
+
+    rc = pthread_rwlockattr_init(&attr);
+    if (rc != 0)
+        panic(rc, "Initialization of pthread_rwlockattr_t failed.");
+    rc = pthread_rwlock_init(&lock->rwlock, &attr);
     if (rc != 0)
         panic(rc, "Initialization of RWLock failed.");
     lock->dynamic = 0;
+    rc = pthread_rwlockattr_destroy(&attr);
+    if (rc != 0)
+        error(rc, "Could not destroy pthread_rwlockattr_t.");
 }
 
 

Reply via email to