Re: Clean up winbindd locking

2003-03-09 Thread Martin Pool
On  8 Mar 2003, Andrew Bartlett <[EMAIL PROTECTED]> wrote:
> On Sat, 2003-03-08 at 21:20, Tim Potter wrote:
> > On Sat, Mar 08, 2003 at 09:10:23PM +1100, Andrew Bartlett wrote:
> > 
> > > Is there any reason I should not apply this patch to Samba HEAD?
> > 
> > I think the patch was eaten by Mailman.  Please re-send as text/plain.
> > 
> > Without even seeing the patch (-: it's definitely a good idea.

That looks very nice.

-- 
Martin 


Re: Clean up winbindd locking

2003-03-08 Thread Andrew Bartlett
On Sat, 2003-03-08 at 21:20, Tim Potter wrote:
> On Sat, Mar 08, 2003 at 09:10:23PM +1100, Andrew Bartlett wrote:
> 
> > Is there any reason I should not apply this patch to Samba HEAD?
> 
> I think the patch was eaten by Mailman.  Please re-send as text/plain.
> 
> Without even seeing the patch (-: it's definitely a good idea.

Actually, I think it was human error this time, but I'll blame mailman
if you like :-)

Andrew,

-- 
Andrew Bartlett [EMAIL PROTECTED]
Manager, Authentication Subsystems, Samba Team  [EMAIL PROTECTED]
Student Network Administrator, Hawker College   [EMAIL PROTECTED]
http://samba.org http://build.samba.org http://hawkerc.net
? Makefile.in-
? config.abartlet
? print_err.patch
? sess_key
? to-3.0.diff
? user_ok.patch
? bin/st1q6nNC
? groupdb/mapping.po
? include/nmbd_dhcp_for_wins.h
? include/smb_interactive.h
? intl/Makefile
? intl/po
? intl/po2tbl.sed
? lib/get_password.c
? lib/rfc1738.c
? libads/libads_proto.h
? libsmb/cliconnect.
? nmbd/nmbd_dhcp_for_wins.c
? nsswitch/.libs
? nsswitch/ntlmauth.c
? pam_smbpass/pam_smb_acct.po
? pam_smbpass/pam_smb_auth.po
? pam_smbpass/pam_smb_passwd.po
? pam_smbpass/support.po
? po/Makefile
? po/POTFILES
? torture/map_extract.c
Index: lib/server_mutex.c
===
RCS file: /data/cvs/samba/source/lib/server_mutex.c,v
retrieving revision 1.3
diff -u -r1.3 server_mutex.c
--- lib/server_mutex.c  16 Jan 2003 20:08:33 -  1.3
+++ lib/server_mutex.c  8 Mar 2003 09:56:44 -
@@ -30,8 +30,6 @@
like the single-connection that NT makes. */
 
 static char *mutex_server_name;
-/* FIXME. ref_count should be allocated per name... JRA. */
-size_t ref_count;
 
 BOOL grab_server_mutex(const char *name)
 {
@@ -40,7 +38,7 @@
DEBUG(0,("grab_server_mutex: malloc failed for %s\n", name));
return False;
}
-   if (!secrets_named_mutex(mutex_server_name, 10, &ref_count)) {
+   if (!secrets_named_mutex(mutex_server_name, 10)) {
DEBUG(10,("grab_server_mutex: failed for %s\n", name));
SAFE_FREE(mutex_server_name);
return False;
@@ -52,7 +50,7 @@
 void release_server_mutex(void)
 {
if (mutex_server_name) {
-   secrets_named_mutex_release(mutex_server_name, &ref_count);
+   secrets_named_mutex_release(mutex_server_name);
SAFE_FREE(mutex_server_name);
}
 }
Index: nsswitch/winbindd_cm.c
===
RCS file: /data/cvs/samba/source/nsswitch/winbindd_cm.c,v
retrieving revision 1.61
diff -u -r1.61 winbindd_cm.c
--- nsswitch/winbindd_cm.c  16 Jan 2003 20:08:33 -  1.61
+++ nsswitch/winbindd_cm.c  8 Mar 2003 09:56:46 -
@@ -302,7 +302,7 @@
 /* Open a connction to the remote server, cache failures for 30 seconds */
 
 static NTSTATUS cm_open_connection(const char *domain, const int pipe_index,
-  struct winbindd_cm_conn *new_conn, BOOL keep_mutex)
+  struct winbindd_cm_conn *new_conn)
 {
struct failed_connection_cache *fcc;
NTSTATUS result;
@@ -310,7 +310,6 @@
struct in_addr dc_ip;
int i;
BOOL retry = True;
-   BOOL got_mutex = False;
 
ZERO_STRUCT(dc_ip);
 
@@ -366,24 +365,21 @@
  new_conn->controller, global_myname(), ipc_domain, ipc_username));
 
for (i = 0; retry && (i < 3); i++) {
-   
-   if (!secrets_named_mutex(new_conn->controller, 
WINBIND_SERVER_MUTEX_WAIT_TIME, &new_conn->mutex_ref_count)) {
+   BOOL got_mutex;
+   if (!(got_mutex = secrets_named_mutex(new_conn->controller, 
WINBIND_SERVER_MUTEX_WAIT_TIME))) {
DEBUG(0,("cm_open_connection: mutex grab failed for %s\n", 
new_conn->controller));
result = NT_STATUS_POSSIBLE_DEADLOCK;
continue;
}
-
-   got_mutex = True;
-
+   
result = cli_full_connection(&new_conn->cli, global_myname(), 
new_conn->controller, 
-   &dc_ip, 0, "IPC$", "IPC", ipc_username, ipc_domain, 
-   ipc_password, 0, &retry);
+&dc_ip, 
CLI_FULL_CONNECTION_ANNONYMOUS_FALLBACK, "IPC$", "IPC", ipc_username, ipc_domain, 
+ipc_password, 0, &retry);
+   
+   secrets_named_mutex_release(new_conn->controller);
 
if (NT_STATUS_IS_OK(result))
break;
-
-   secrets_named_mutex_release(new_conn->controller, 
&new_conn->mutex_ref_count);
-   got_mutex = False;
}
 
SAFE_FREE(ipc_username);
@@ -391,8 +387,6 @@
SAFE_FREE(ipc_password);
 
if (!NT_STATUS_IS_OK(result)) {
-   if (got_mutex)
-  

Re: Clean up winbindd locking

2003-03-08 Thread Tim Potter
On Sat, Mar 08, 2003 at 09:10:23PM +1100, Andrew Bartlett wrote:

> Is there any reason I should not apply this patch to Samba HEAD?

I think the patch was eaten by Mailman.  Please re-send as text/plain.

Without even seeing the patch (-: it's definitely a good idea.


Tim.