svn commit: samba r2350 - in trunk/source/nsswitch: .

vlendec at samba.org vlendec at samba.org
Wed Sep 15 14:56:42 GMT 2004


Author: vlendec
Date: 2004-09-15 14:56:42 +0000 (Wed, 15 Sep 2004)
New Revision: 2350

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/trunk/source/nsswitch&rev=2350&nolog=1

Log:
Convert the list of requests to send out to dual daemons to a standard dual
linked list.

Identifying a request sent out to a dual daemon by the socket is not
enough. We might have outstanding requests from normal cache updates. Change
the identifier to a message id.

Volker

Modified:
   trunk/source/nsswitch/winbindd.c
   trunk/source/nsswitch/winbindd.h
   trunk/source/nsswitch/winbindd_dual.c
   trunk/source/nsswitch/winbindd_nss.h


Changeset:
Modified: trunk/source/nsswitch/winbindd.c
===================================================================
--- trunk/source/nsswitch/winbindd.c	2004-09-15 14:01:26 UTC (rev 2349)
+++ trunk/source/nsswitch/winbindd.c	2004-09-15 14:56:42 UTC (rev 2350)
@@ -208,26 +208,26 @@
 static void msg_finished(int msg_type, pid_t src, void *buf, size_t len)
 {
 	struct winbindd_cli_state *state;
-	int *fd;
+	int *msgid;
 
 	DEBUG(5, ("Got finished message\n"));
 
-	if (len != sizeof(*fd)) {
+	if (len != sizeof(*msgid)) {
 		DEBUG(0, ("Wrong buffer size in message: %d\n", len));
 		return;
 	}
 
 	dual_finished(src);
 
-	fd = (int *)buf;
+	msgid = (int *)buf;
 
-	DEBUGADD(10, ("fd = %d\n", *fd));
+	DEBUGADD(10, ("got msgid %d\n", *msgid));
 
 	for (state = winbindd_client_list(); state; state = state->next) {
 		if (state->response.result != WINBINDD_PENDING)
 			continue;
 
-		if (state->sock != *fd)
+		if (state->msgid != *msgid)
 			continue;
 
 		state->response.result = state->continuation(state, src);
@@ -236,7 +236,6 @@
 			if (state->send_to_background) {
 				extern BOOL background_process;
 				background_process = True;
-				state->request.client_fd = state->sock;
 				dual_send_request(state);
 			}
 			return;
@@ -570,7 +569,6 @@
 	if (opt_dual_daemon && state->send_to_background) {
 		extern BOOL background_process;
 		background_process = True;
-		state->request.client_fd = state->sock;
 		dual_send_request(state);
 	}
 }
@@ -899,6 +897,10 @@
                     
 					if (state->read_buf_len == 
 					    sizeof(state->request)) {
+						static int msgid;
+						msgid += 1;
+						state->msgid = msgid;
+						state->request.msgid = msgid;
 						winbind_process_packet(state);
 						winbindd_demote_client(state);
 						goto again;

Modified: trunk/source/nsswitch/winbindd.h
===================================================================
--- trunk/source/nsswitch/winbindd.h	2004-09-15 14:01:26 UTC (rev 2349)
+++ trunk/source/nsswitch/winbindd.h	2004-09-15 14:56:42 UTC (rev 2350)
@@ -44,6 +44,7 @@
 	time_t last_access;                       /* Time of last access (read or write) */
 	BOOL privileged;                           /* Is the client 'privileged' */
 
+	int msgid;				  /* message id to expect from dual */
 	BOOL send_to_background;
 	enum winbindd_result (*continuation)(struct winbindd_cli_state *cli,
 					     pid_t dual_daemon);

Modified: trunk/source/nsswitch/winbindd_dual.c
===================================================================
--- trunk/source/nsswitch/winbindd_dual.c	2004-09-15 14:01:26 UTC (rev 2349)
+++ trunk/source/nsswitch/winbindd_dual.c	2004-09-15 14:56:42 UTC (rev 2350)
@@ -42,7 +42,7 @@
 
 /* a list of requests ready to be sent to the dual daemon */
 struct dual_list {
-	struct dual_list *next;
+	struct dual_list *next, *prev;
 	char *data;
 	int length;
 };
@@ -60,7 +60,6 @@
 static struct dual_child *child_list;
 
 static struct dual_list *dual_list;
-static struct dual_list *dual_list_end;
 
 static BOOL dual_schedule_request(void)
 {
@@ -71,7 +70,7 @@
 		return False;
 
 	for (child = child_list; child != NULL; child = child->next) {
-		struct dual_list *next;
+		struct dual_list *this;
 
 		if (child->busy) {
 			extern int max_busy_children;
@@ -81,17 +80,21 @@
 			continue;
 		}
 
+		SMB_ASSERT(child->data == NULL);
+
+		DEBUG(10, ("scheduling %d\n",
+			   ((struct winbindd_request *)(dual_list->data))->cmd));
+
 		child->data = dual_list->data;
 		child->length = dual_list->length;
 		child->offset = 0;
 		child->busy = True;
 
-		next = dual_list->next;
-		free(dual_list);
-		dual_list = next;
-		if (dual_list == NULL)
-			dual_list_end = NULL;
+		this = dual_list;
 
+		DLIST_REMOVE(dual_list, this);
+		free(this);
+
 		return True;
 	}
 	return False;
@@ -133,16 +136,12 @@
 
 static void resend_request(char *data, int length)
 {
-	struct dual_list *list;
+	struct dual_list *req;
 
-	list = malloc(sizeof(*list));
-	list->next = dual_list;
-	list->data = data;
-	list->length = length;
-	dual_list = list;
-
-	if (dual_list_end == NULL)
-		dual_list_end = list;
+	req = malloc(sizeof(*req));
+	req->data = data;
+	req->length = length;
+	DLIST_ADD(dual_list, req);
 }
 
 /*
@@ -209,25 +208,21 @@
 */
 void dual_send_request(struct winbindd_cli_state *state)
 {
-	struct dual_list *list;
+	struct dual_list *req, *tmp;
 
 	if (!background_process) return;
 
-	list = malloc(sizeof(*list));
-	if (!list) return;
+	DEBUG(10, ("dual_send_request: cmd=%d, msgid=%d\n",
+		   state->request.cmd, state->request.msgid));
 
-	list->next = NULL;
-	list->data = memdup(&state->request, sizeof(state->request));
-	list->length = sizeof(state->request);
-	
-	if (!dual_list_end) {
-		dual_list = list;
-		dual_list_end = list;
-	} else {
-		dual_list_end->next = list;
-		dual_list_end = list;
-	}
+	req = malloc(sizeof(*req));
+	if (!req) return;
 
+	req->next = NULL;
+	req->data = memdup(&state->request, sizeof(state->request));
+	req->length = sizeof(state->request);
+	DLIST_ADD_END(dual_list, req, tmp);
+
 	background_process = False;
 }
 
@@ -322,8 +317,8 @@
 						     &state.response);
 
 			message_send_pid(getppid(), MSG_WINBIND_FINISHED,
-					 &state.request.client_fd,
-					 sizeof(state.request.client_fd),
+					 &state.request.msgid,
+					 sizeof(state.request.msgid),
 					 True);
 			SAFE_FREE(state.response.extra_data);
 

Modified: trunk/source/nsswitch/winbindd_nss.h
===================================================================
--- trunk/source/nsswitch/winbindd_nss.h	2004-09-15 14:01:26 UTC (rev 2349)
+++ trunk/source/nsswitch/winbindd_nss.h	2004-09-15 14:56:42 UTC (rev 2350)
@@ -170,7 +170,7 @@
 	uint32 flags;            /* flags relavant to a given request */
 	fstring domain_name;	/* name of domain for which the request applies */
 
-	int client_fd; 		/* Uniquely identify a request, used in
+	int msgid; 		/* Uniquely identify a request, used in
 				 * MSG_WINBINDD_FINISHED from dual daemon to
 				 * parent. */
 



More information about the samba-cvs mailing list