git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Small bugfixes for http-push.c

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Nov 7, 2005, 18:23 UTC
Message-ID
<Pine.LNX.4.63.0511071918520.14111@wbgn013.biozentrum.uni-wuerzburg.de>
This patch fixes three things:
- older libexpat does not know about enum XML_Status
- as in my patch for http-fetch, do not rely on a curl result in
	free()d data
- calloc the new_lock structure
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
	I verified in a small scale test that it works now. The buglets
	showed only on my iBook, not on any Linux box I tried.
	The calloc'ing of the new_lock structure is necessary, because
	activelock_cdata() relies on several members being 0 until
	set by start_activelock_element().
	The problem I was experiencing with a crash in 
	cleanup_multi_handle() was due to the curl result not being
	interpreted correctly.
	Unfortunately, valgrind does not work on macosx, so it could
	not help me.
	Note: http-push shares a lot of code with http-fetch. It might
	be a good idea to refactor them (after some more out-ironing).
 http-push.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/http-push.c b/http-push.c
index c10067c..5532d02 100644
--- a/http-push.c
+++ b/http-push.c
@@ -28,6 +28,15 @@ static const char http_push_usage[] =
 #define NO_CURL_EASY_DUPHANDLE
 #endif
 
+#ifndef XML_STATUS_OK
+enum XML_Status {
+  XML_STATUS_OK = 1,
+  XML_STATUS_ERROR = 0
+};
+#define XML_STATUS_OK    1
+#define XML_STATUS_ERROR 0
+#endif
+
 #define RANGE_HEADER_SIZE 30
 
 /* DAV method names and request body templates */
@@ -728,11 +737,12 @@ void process_curl_messages(void)
 			       slot->curl != curl_message->easy_handle)
 				slot = slot->next;
 			if (slot != NULL) {
+				int curl_result = curl_message->data.result;
 				curl_multi_remove_handle(curlm, slot->curl);
 				active_requests--;
 				slot->done = 1;
 				slot->in_use = 0;
-				slot->curl_result = curl_message->data.result;
+				slot->curl_result = curl_result;
 				curl_easy_getinfo(slot->curl,
 						  CURLINFO_HTTP_CODE,
 						  &slot->http_code);
@@ -1230,7 +1240,7 @@ struct active_lock *lock_remote(char *fi
 	in_buffer.posn = 0;
 	in_buffer.buffer = in_data;
 
-	new_lock = xmalloc(sizeof(*new_lock));
+	new_lock = xcalloc(1, sizeof(*new_lock));
 	new_lock->owner = NULL;
 	new_lock->token = NULL;
 	new_lock->timeout = -1;
Message 1 of 1 in “Small bugfixes for http-push.c”
  1. Small bugfixes for http-push.cJohannes Schindelin, Nov 7, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.