svn commit: samba r16983 - in branches/tmp/vl-messaging/source/lib: .

vlendec at samba.org vlendec at samba.org
Wed Jul 12 14:45:36 GMT 2006


Author: vlendec
Date: 2006-07-12 14:45:36 +0000 (Wed, 12 Jul 2006)
New Revision: 16983

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16983

Log:
Reformatting
Modified:
   branches/tmp/vl-messaging/source/lib/messages_stream.c


Changeset:
Modified: branches/tmp/vl-messaging/source/lib/messages_stream.c
===================================================================
--- branches/tmp/vl-messaging/source/lib/messages_stream.c	2006-07-12 14:33:25 UTC (rev 16982)
+++ branches/tmp/vl-messaging/source/lib/messages_stream.c	2006-07-12 14:45:36 UTC (rev 16983)
@@ -316,11 +316,11 @@
 ****************************************************************************/
 
 static BOOL message_send_pid_stream_internal(struct messaging_client *client,
-											 struct process_id from,
-											 int msg_type,
-											 const void *buf, size_t len,
-											 BOOL duplicates_allowed,
-											 unsigned int timeout)
+					     struct process_id from,
+					     int msg_type,
+					     const void *buf, size_t len,
+					     BOOL duplicates_allowed,
+					     unsigned int timeout)
 {
 	struct message_list *li, *tmp;
 	uint8_t* buffer;
@@ -378,9 +378,10 @@
 
 	if(mtype == MESSAGING_TYPE_DISPATCHER) {
 		if(procid_is_local(pid)) {		
-			/* It's a problem: all local clients should be already connected to
-			   the dispatcher daemon. */
-			DEBUG(0, ("Trying to send message to unconnected client\n"));
+			/* It's a problem: all local clients should be already
+			   connected to the dispatcher daemon. */
+			DEBUG(0, ("Trying to send message to unconnected "
+				  "client\n"));
 			return NULL;
 		}
 
@@ -390,7 +391,8 @@
 		result->pid.pid = MESSAGING_DISPATCHER_PID;
 		result->fd = socket(AF_INET, SOCK_STREAM, 0);
 		if (result->fd < 0) {
-			DEBUG(5, ("Could not create tcp socket: %s\n", strerror(errno)));
+			DEBUG(5, ("Could not create tcp socket: %s\n",
+				  strerror(errno)));
 			TALLOC_FREE(result);
 			return NULL;
 		}
@@ -400,7 +402,7 @@
 		sinaddr.sin_port = htons(lp_messaging_port());
 #else 
 		DEBUG(0, ("Cannot connect to a remote client - "
-				  "clusterwide messaging is disabled\n"));
+			  "clusterwide messaging is disabled\n"));
 		return NULL;
 #endif /* WITH_CLUSTERWIDE_MESSAGING */
 	} else {
@@ -408,14 +410,15 @@
 		
 		result->fd = socket(AF_UNIX, SOCK_STREAM, 0);
 		if (result->fd < 0) {
-			DEBUG(5, ("Could not create unix socket: %s\n", strerror(errno)));
+			DEBUG(5, ("Could not create unix socket: %s\n",
+				  strerror(errno)));
 			TALLOC_FREE(result);
 			return NULL;
 		}
 		
 		sunaddr.sun_family = AF_UNIX;
 		strncpy(sunaddr.sun_path, message_path(pid),
-				sizeof(sunaddr.sun_path)-1);
+			sizeof(sunaddr.sun_path)-1);
 	}		
 	
 	talloc_set_destructor(result, messaging_client_destr);
@@ -429,7 +432,7 @@
 #ifdef WITH_CLUSTERWIDE_MESSAGING
 	if(mtype == MESSAGING_TYPE_DISPATCHER) {
 		if (connect(result->fd, (struct sockaddr *)&sinaddr,
-					sizeof(sinaddr)) == 0) {
+			    sizeof(sinaddr)) == 0) {
 			result->connected = True;
 			goto done;
 		}
@@ -437,7 +440,7 @@
 #endif /* WITH_CLUSTERWIDE_MESSAGING */
 	{
 		if (connect(result->fd, (struct sockaddr *)&sunaddr,
-					sizeof(sunaddr)) == 0) {
+			    sizeof(sunaddr)) == 0) {
 			result->connected = True;
 			goto done;
 		}		
@@ -459,11 +462,11 @@
 	if(mtype == MESSAGING_TYPE_STREAM) {
 		/* Send HELLO message to the new client (local clients only) */
 		message_send_pid_stream_internal(result, procid_self(),
-										 MSG_HELLO, NULL, 0, False, 0);
+						 MSG_HELLO, NULL, 0, False, 0);
 	}
 
 	DEBUG(10, ("Connecting to client %s\n",
-			   procid_str_static(&result->pid)));
+		   procid_str_static(&result->pid)));
 
 	DLIST_ADD(clients_cache, result);
 	return result;
@@ -476,7 +479,7 @@
 static BOOL container_full(const struct message_list *li)
 {
 	return ((li != NULL) && (li->processed != 0) &&
-			(li->processed == li->msg->len));
+		(li->processed == li->msg->len));
 }
 
 /****************************************************************************
@@ -484,8 +487,8 @@
 ****************************************************************************/
 
 static struct message_list *read_from_stream_socket(int fd,
-													TALLOC_CTX *mem_ctx,
-													struct message_list *cnt)
+						    TALLOC_CTX *mem_ctx,
+						    struct message_list *cnt)
 {
 	size_t len = 0, to_read;
 	ssize_t nread;
@@ -520,7 +523,7 @@
 	}
 	if (nread < 0) {
 		DEBUG(5, ("Error while reading from socket (errno = %d)\n",
-				   errno));
+			  errno));
 		TALLOC_FREE(cnt);
 		return NULL;
 	}
@@ -529,14 +532,16 @@
 
 	if (cnt->msg == NULL) {
 		if(cnt->processed < sizeof(size_t)) {
-			DEBUG(0, ("Received less that %d bytes!\n", sizeof(size_t)));
+			DEBUG(0, ("Received less that %d bytes!\n",
+				  sizeof(size_t)));
 			TALLOC_FREE(cnt);
 			return NULL;
 		}
 
 		DEBUG(10, ("Receiving msg of length %d\n",
-			  len));
-		cnt->msg = (struct message_rec*)TALLOC_ZERO_ARRAY(cnt, char, len);
+			   len));
+		cnt->msg = (struct message_rec*)TALLOC_ZERO_ARRAY(cnt, char,
+								  len);
 		if (cnt->msg == NULL) {
 			DEBUG(0, ("talloc failed\n"));
 			TALLOC_FREE(cnt);
@@ -553,9 +558,9 @@
 ****************************************************************************/
 
 static BOOL receive_one_message(int fd,
-								TALLOC_CTX *mem_ctx,
-								struct message_list **msg,
-								BOOL* received)
+				TALLOC_CTX *mem_ctx,
+				struct message_list **msg,
+				BOOL* received)
 {
 	*received = False;
 	*msg = read_from_stream_socket(fd, mem_ctx, *msg);
@@ -599,11 +604,11 @@
 			msg_rec = (struct message_rec *)c->incoming->msg;
 			if (msg_rec->msg_type != MSG_HELLO) {
 				DEBUG(0, ("Client %s did not say hello\n",
-						  procid_str_static(&c->pid)));
+					  procid_str_static(&c->pid)));
 				return False;
 			}
 			DEBUG(10, ("Got hello from %s\n",
-					   procid_str_static(&msg_rec->src)));
+				   procid_str_static(&msg_rec->src)));
 			c->pid = msg_rec->src;
 			TALLOC_FREE((c->incoming));
 		}
@@ -626,11 +631,11 @@
 	}
 
 	sent = sys_write(fd, (uint8_t *)li->msg + li->processed,
-					 li->msg->len - li->processed);
+			 li->msg->len - li->processed);
 
 	if (sent < 0) {
 		DEBUG(5, ("sending data failed: %s\n",
-				  strerror(errno)));
+			  strerror(errno)));
 		return False;
 	}
 
@@ -684,14 +689,14 @@
 		client = connect_client(&to);
 		if(client == NULL) {
 			DEBUG(5, ("Can't connect to client %s\n",
-					  procid_str_static(&to)));
+				  procid_str_static(&to)));
 			return False;
 		}
 	}
 
 	return message_send_pid_stream_internal(client, from, msg_type,
-											buf, len,
-											duplicates_allowed, timeout);
+						buf, len,
+						duplicates_allowed, timeout);
 }
 
 /****************************************************************************
@@ -716,7 +721,7 @@
 ****************************************************************************/
 
 unsigned int message_receive_stream(fd_set *rfds, fd_set *wfds,
-									struct message_list **received)
+				    struct message_list **received)
 {
 	unsigned int affected = 0;
 	struct messaging_client *client;
@@ -726,8 +731,8 @@
 		struct messaging_client *c = client;
 		
 		if (!client->connected && 
-			FD_ISSET(client->fd, rfds) &&
-			FD_ISSET(client->fd, wfds)) {
+		    FD_ISSET(client->fd, rfds) &&
+		    FD_ISSET(client->fd, wfds)) {
 			affected += 2;
 			goto remove_client;
 		}
@@ -754,8 +759,9 @@
 					DEBUG(0, ("talloc failed\n"));
 					return 0;
 				}
-				li->msg = (struct message_rec*)TALLOC_ARRAY(li, uint8_t,
-							client->incoming->msg->len);
+				li->msg = (struct message_rec*)TALLOC_ARRAY(
+					li, uint8_t,
+					client->incoming->msg->len);
 				if(li->msg == NULL) {
 					DEBUG(0, ("talloc failed\n"));
 					TALLOC_FREE(li);
@@ -763,13 +769,14 @@
 				}
 				
 				memcpy(li->msg, client->incoming->msg,
-					   client->incoming->msg->len);
+				       client->incoming->msg->len);
 				
 				DLIST_ADD_END((*received), li, tmp);
 
 				/* 
-				   We don't free client->incoming, because it will be
-				   freed in a next read_from_stream_socket call.
+				   We don't free client->incoming, because it
+				   will be freed in a next
+				   read_from_stream_socket call.
 				*/
 			}
 		}
@@ -788,7 +795,7 @@
 	remove_client:
 		
 		DEBUG(5, ("Connection to %s failed\n",
-				  procid_str_static(&client->pid)));
+			  procid_str_static(&client->pid)));
 		client = client->next;
 		remove_client(c);
 	}
@@ -865,7 +872,7 @@
 ****************************************************************************/
 
 static void dispatch_loop(int *parent, int unix_listener, int tcp_listener,
-						  BOOL is_lockd, struct process_id *lockd)
+			  BOOL is_lockd, struct process_id *lockd)
 {
 	fd_set rfds, wfds;
 	int maxfd = 0;
@@ -926,9 +933,9 @@
 
 		asprintf(&sname, "%s", procid_str_static(&msg->src));
 		DEBUG(10, ("Received message of type %d from %s to %s\n",
-				   msg->msg_type,
-				   sname,
-				   procid_str_static(&msg->dest)));
+			   msg->msg_type,
+			   sname,
+			   procid_str_static(&msg->dest)));
 		SAFE_FREE(sname);
 
 		buffer = (char *)msg + sizeof(struct message_rec);
@@ -937,13 +944,14 @@
 		if(is_lockd && procid_equal(lockd, &msg->dest)) {
 			/* a db/locking request */
 			process_db_request(lockd,
-							   &msg->src, msg->msg_type,
-							   buffer, len);
+					   &msg->src, msg->msg_type,
+					   buffer, len);
 		} else {
-			/* just send to the receiver:
-			   one more copy - from main context to client's context */
-			message_send_pid_stream(msg->src, msg->dest, msg->msg_type,
-									buffer, len, False, 0);
+			/* just send to the receiver: one more copy - from
+			   main context to client's context */
+			message_send_pid_stream(msg->src, msg->dest,
+						msg->msg_type,
+						buffer, len, False, 0);
 		}
 		received = received->next;
 		TALLOC_FREE(tmp);
@@ -966,7 +974,7 @@
 
 #ifdef WITH_CLUSTERWIDE_MESSAGING
 	asprintf(&name, "%s:%s", lp_messaging_address(),
-			 MESSAGING_DISPATCHER_SOCKET);
+		 MESSAGING_DISPATCHER_SOCKET);
 #else
 	asprintf(&name, "%s", MESSAGING_DISPATCHER_SOCKET);
 #endif /* WITH_CLUSTERWIDE_MESSAGING */
@@ -1013,7 +1021,7 @@
 
 	/* 
 	   Presently we don't remove socket & lock file. Should be fixed later
-	 */
+	*/
 
 	DEBUG(10, ("Dispatcher child exit.\n"));
 	exit(0);
@@ -1070,7 +1078,7 @@
 
 	if((enum locking_type)lp_locking_type() == LOCKING_TYPE_MESSAGES) {
 		message_register(MSG_DB_INIT, handle_init_return);	
-		message_register(MSG_DB_FETCHLOCK, handle_fetchlock_return);	
+		message_register(MSG_DB_FETCHLOCK, handle_fetchlock_return);
 	}
 
 	ZERO_STRUCT(sunaddr);
@@ -1079,7 +1087,8 @@
 
 	sock = socket(AF_UNIX, SOCK_STREAM, 0);
 	if (sock < 0) {
-		DEBUG(5, ("Could not create socket [first]: %s\n", strerror(errno)));
+		DEBUG(5, ("Could not create socket [first]: %s\n",
+			  strerror(errno)));
 		return -1;
 	}
 
@@ -1103,7 +1112,8 @@
 
 	sock = socket(AF_UNIX, SOCK_STREAM, 0);
 	if (sock < 0) {
-		DEBUG(5, ("Could not create socket [second]: %s\n", strerror(errno)));
+		DEBUG(5, ("Could not create socket [second]: %s\n",
+			  strerror(errno)));
 		close(pidfile);
 		return -1;
 	}
@@ -1160,7 +1170,8 @@
 
 	sock = socket(AF_UNIX, SOCK_STREAM, 0);
 	if (sock < 0) {
-		DEBUG(5, ("Could not create socket [third]: %s\n", strerror(errno)));
+		DEBUG(5, ("Could not create socket [third]: %s\n",
+			  strerror(errno)));
 		close(pidfile);
 		return -1;
 	}
@@ -1182,7 +1193,7 @@
 	DEBUG(10, ("Dispatcher connected, say hello.\n"));
 	/* say HELLO to the dispatcher to identify oneself */
 	message_send_pid_socket(pid_to_procid(MESSAGING_DISPATCHER_PID),
-							MSG_HELLO, NULL, 0, False, 0);
+				MSG_HELLO, NULL, 0, False, 0);
 	return sock;
 }
 



More information about the samba-cvs mailing list