[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [hobbit] Todays snapshot 20080406



On Mon, Apr 07, 2008 at 08:52:31AM +0200, Lars Ebeling wrote:
>> I restored yesterdays snapshot from backup, and followed the tutorial 
>> mentioned above. Now yesterdays snapshot works.
> I was to fast ;)
>
> All built in tests went purple except hobbitd

Should work better with this patch on top of the snapshot.


Henrik

--- beta/snapshot/hobbitd/hobbitd.c	2008-04-06 08:15:55.000000000 +0200
+++ ./hobbitd/hobbitd.c	2008-04-07 12:49:02.000000000 +0200
@@ -194,6 +194,7 @@
 	       SSLREAD_RESPONDING, SSLWRITE_RESPONDING,
 	       RECEIVING, RESPONDING } doingwhat;	/* Communications state */
 	int compressionok;		/* Remote end can handle compression */
+	int onelinercheckdone;		/* Flag if we have checked if this is a one-line command */
 	void *sslobj;			/* SSL object for SSL-enabled connections */
 	time_t timeout;			/* When the timeout for this connection happens */
 	struct conn_t *next;
@@ -4533,12 +4534,24 @@
 		"hostinfo",
 		"clientlog",
 		"ghostlist",
-		"multisrclist",
-		NULL
+		"multisrclist"
 	};
 	int i;
-	
-	if (strchr(cn->buf, '\n') == NULL) return 0;
+
+	/* If we already did the check, skip doing it again (it must be a multi-line command) */
+	if (cn->onelinercheckdone) return 0;
+
+	/* 
+	 * This check is done when we have a newline in the buffer.
+	 * We check the "oneliners" array for a match just below, and
+	 * if there is one then the command is done (so onelinercheckdone
+	 * becomes irrelevant). If there is no match but we have a NL
+	 * now, then there is no way it can be a one-line command so
+	 * set onelinercheckdone TRUE to skip doing the tests again.
+	 */
+	cn->onelinercheckdone = (strchr(cn->buf, '\n') != NULL);
+
+	/* See if the command is one of our one-line commands */
 	for (i=0; (i < (sizeof(oneliners) / sizeof(oneliners[0]))); i++) {
 		if (cn->buflen < strlen(oneliners[i])) continue;
 		if (strncmp(cn->buf, oneliners[i], strlen(oneliners[i])) == 0) return 1;
@@ -5166,8 +5179,9 @@
 					cwalk->bufp += n;
 					cwalk->buflen += n;
 					*(cwalk->bufp) = '\0';
-					if (commandiscomplete(cwalk)) 
+					if (commandiscomplete(cwalk)) {
 						do_message(cwalk, "");
+					}
 					else if ((cwalk->bufsz - cwalk->buflen) < 2048) {
 						if (cwalk->bufsz < MAX_HOBBIT_INBUFSZ) {
 							cwalk->bufsz += HOBBIT_INBUF_INCREMENT;