Skip to contentSkip to conversation

cluster/dlm/lib libdlm.c

Cluster-devel [email protected] 1 participant 1 message Jan 31, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Changes by: pcaulfield at sourceware.org 2007-01-31 10:53:47

Modified files:
dlm/lib : libdlm.c

Log message:
Read the LVB every time, rather than not at all.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/lib/libdlm.c.diff?cvsroot=cluster&r1=1.32&r2=1.33

dlm/lib/libdlm.c +9 -5
@@ -406,14 +406,14 @@
 
 static int do_dlm_dispatch(int fd)
 {
-    struct dlm_lock_result resultbuf;
-    struct dlm_lock_result *result = &resultbuf;
+    char resultbuf[sizeof(struct dlm_lock_result) + DLM_USER_LVB_LEN];
+    struct dlm_lock_result *result = (struct dlm_lock_result *)resultbuf;
     char *fullresult = NULL;
     int status;
     void (*astaddr)(void *astarg);
 
-    /* Just read the header first */
-    status = read(fd, result, sizeof(struct dlm_lock_result));
+    /* Just read the header & LVB first */
+    status = read(fd, result, sizeof(resultbuf));
     if (status <= 0)
 	return -1;
 
@@ -433,6 +433,10 @@
 	if (newstat == result->length)
 		result = (struct dlm_lock_result *)fullresult;
     }
+    else
+    {
+	fullresult = resultbuf;
+    }
 
     /* Copy lksb to user's buffer - except the LVB ptr */
     memcpy(result->user_lksb, &result->lksb, sizeof(struct dlm_lksb) - sizeof(char*));
@@ -468,7 +472,7 @@
 	astaddr(result->user_astparam);
     }
 
-    if (fullresult)
+    if (fullresult != resultbuf)
 	free(fullresult);
     return 0;
 }