diff -Naur afpfs-ng-0.8.1/lib/dsi.c afpfs-ng-0.8.1.patch/lib/dsi.c
--- afpfs-ng-0.8.1/lib/dsi.c	2011-09-10 12:21:39.948437027 +0200
+++ afpfs-ng-0.8.1.patch/lib/dsi.c	2011-09-10 12:25:57.688903825 +0200
@@ -64,7 +64,7 @@
 	rx.size=0;
 	dsi_setup_header(server,&header,DSI_DSIGetStatus);
 	/* We're intentionally ignoring the results */
-	ret=dsi_send(server,(char *) &header,sizeof(struct dsi_header),20,
+	ret=dsi_send(server,(char *) &header,sizeof(struct dsi_header),60,
 		0,(void *) &rx);
 
 	free(rx.data);
@@ -197,6 +197,7 @@
 	new_request->other=other;
 	new_request->wait=wait;
 	new_request->next=NULL;
+      	new_request->done_waiting=0;
 
 	pthread_mutex_lock(&server->request_queue_mutex);
 	if (server->command_requests==NULL) {
@@ -208,7 +209,8 @@
 	server->stats.requests_pending++;
 	pthread_mutex_unlock(&server->request_queue_mutex);
 
-	pthread_cond_init(&new_request->condition_cond,NULL);
+	pthread_cond_init(&new_request->waiting_cond,NULL);
+	pthread_mutex_init(&new_request->waiting_mutex,NULL);
 
 	if (server->connect_state==SERVER_STATE_DISCONNECTED) {
 		char mesg[1024];
@@ -240,16 +242,12 @@
 	server->stats.tx_bytes+=size;
 	pthread_mutex_unlock(&server->send_mutex);
 
-	int tmpwait=new_request->wait;
 	#ifdef DEBUG_DSI
 	printf("=== Waiting for response for %d %s\n",
 		new_request->requestid,
 		afp_get_command_name(new_request->subcommand));
 	#endif
-	if (tmpwait<0) {
-
-		pthread_mutex_t     mutex = PTHREAD_MUTEX_INITIALIZER;
-		pthread_mutex_lock(&mutex);
+	if (new_request->wait<0) {
 
 		/* Wait forever */
 		#ifdef DEBUG_DSI
@@ -258,14 +256,17 @@
 			afp_get_command_name(new_request->subcommand));
 		#endif
 
-		rc=pthread_cond_wait( 
-			&new_request->condition_cond, 
-				&mutex );
-		pthread_mutex_unlock(&mutex);
-
-	} else if (tmpwait>0) {
-		pthread_mutex_t     mutex = PTHREAD_MUTEX_INITIALIZER;
-		pthread_mutex_lock(&mutex);
+		pthread_mutex_lock(&new_request->waiting_mutex);
+
+		if (new_request->done_waiting==0)
+			rc=pthread_cond_wait( 
+				&new_request->waiting_cond, 
+					&new_request->waiting_mutex );
+
+		pthread_mutex_unlock(&new_request->waiting_mutex);
+
+	} else if (new_request->wait>0) {
+		/* wait for new_request->wait seconds */
 
 		#ifdef DEBUG_DSI
 		printf("=== Waiting for %d %s, for %ds\n",
@@ -283,13 +284,15 @@
 			printf("=== Changing my mind, no longer waiting for %d\n",
 				new_request->requestid);
 			#endif
-			pthread_mutex_unlock(&mutex);
 			goto skip;
 		}
-		rc=pthread_cond_timedwait( 
-			&new_request->condition_cond, 
-			&mutex,&ts);
-		pthread_mutex_unlock(&mutex);
+		pthread_mutex_lock(&new_request->waiting_mutex);
+		if (new_request->done_waiting==0) 
+			rc=pthread_cond_timedwait( 
+				&new_request->waiting_cond, 
+				&new_request->waiting_mutex,&ts);
+		pthread_mutex_unlock(&new_request->waiting_mutex);
+
 		if (rc==ETIMEDOUT) {
 /* FIXME: should handle this case properly */
 			#ifdef DEBUG_DSI
@@ -299,6 +302,7 @@
 			goto out;
 		}
 	} else {
+                /* Don't wait */
 		#ifdef DEBUG_DSI
 		printf("=== Skipping wait altogether for %d\n",new_request->requestid);
 		#endif
@@ -474,7 +478,7 @@
 	}
 	server->flags=ntohs(reply1->flags);
 
-	p=(void *)((unsigned long) server->incoming_buffer + sizeof(*reply1));
+	p=(void *)((unsigned int) server->incoming_buffer + sizeof(*reply1));
 	p+=copy_from_pascal(server->server_name,p,AFP_SERVER_NAME_LEN)+1;
 
 	/* Now work our way through the variable bits */
@@ -577,6 +581,7 @@
 	unsigned char mins=0;
 	unsigned char checkmessage=0;
 
+	memset(mesg,0,AFP_LOGINMESG_LEN);
 
 	/* The logic here's undocumented.  If we get an attention packet and
 	   there's no flag, then go check the message.  Also, go check the
@@ -757,7 +762,7 @@
 		printf("<<< read() of rest of AFP, %d bytes\n",amount_to_read);
 		#endif
 		ret = read(server->fd, (void *)
-		(((unsigned long) server->incoming_buffer)+server->data_read),
+		(((unsigned int) server->incoming_buffer)+server->data_read),
 			amount_to_read);
 		if (ret<0) return -1;
 		if (ret==0) {
@@ -862,8 +867,11 @@
 			#ifdef DEBUG_DSI
 			printf("<<< Signalling %d, returning %d or %d\n",request->requestid,request->return_code,rc);
 			#endif
+			pthread_mutex_lock(&request->waiting_mutex);
 			request->wait=0;
-			pthread_cond_signal(&request->condition_cond);
+			request->done_waiting=1;
+			pthread_cond_signal(&request->waiting_cond);
+			pthread_mutex_unlock(&request->waiting_mutex);
 		} else {
 			dsi_remove_from_request_queue(server,request);
 		}
