The branch, master has been updated
       via  9f25ad4 librpc: Shorten dcerpc_binding_handle_call a bit
       via  7982d2a librpc: Use tevent_req_poll_ntstatus
       via  20bede7 libsmbclient: Fix typos
       via  fffb701 tsocket: Add some const
       via  cf86f3e gencache: Simplify gencache_init a bit
      from  c71d6ec genrand: Slightly simplify do_reseed

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 9f25ad44a93da09b3a7c14a4a1a0e78c5a1b529c
Author: Volker Lendecke <v...@samba.org>
Date:   Thu Jun 6 11:37:59 2013 +0200

    librpc: Shorten dcerpc_binding_handle_call a bit
    
    ... saves 200 bytes on 64 bit Linux with -O3
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Stefan Metzmacher <me...@samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <me...@samba.org>
    Autobuild-Date(master): Fri Jun 14 22:27:43 CEST 2013 on sn-devel-104

commit 7982d2aff89c7ff8a2371163bad5f9f88be6af46
Author: Volker Lendecke <v...@samba.org>
Date:   Thu Jun 6 11:31:37 2013 +0200

    librpc: Use tevent_req_poll_ntstatus
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Stefan Metzmacher <me...@samba.org>

commit 20bede7baa3576aa0f97ceb2533db6e33d587b69
Author: Volker Lendecke <v...@samba.org>
Date:   Thu May 16 10:26:09 2013 +0200

    libsmbclient: Fix typos
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Stefan Metzmacher <me...@samba.org>

commit fffb70168d8031dc1999fab963263ac7d3a2442a
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Jun 11 19:36:09 2013 +0200

    tsocket: Add some const
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Stefan Metzmacher <me...@samba.org>

commit cf86f3e81b4e228d5f85cac283c51ca7d5e0cd16
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Jun 11 21:03:22 2013 +0200

    gencache: Simplify gencache_init a bit
    
    Use the implicit cleanup facility CLEAR_IF_FIRST provides
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Stefan Metzmacher <me...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/tsocket/tsocket.h          |    4 ++--
 lib/tsocket/tsocket_bsd.c      |    2 +-
 librpc/rpc/binding_handle.c    |   22 +++++++---------------
 source3/include/libsmbclient.h |    8 ++++----
 source3/lib/gencache.c         |   29 ++++++++++++++++-------------
 5 files changed, 30 insertions(+), 35 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tsocket/tsocket.h b/lib/tsocket/tsocket.h
index 98f864e..6b0eef6 100644
--- a/lib/tsocket/tsocket.h
+++ b/lib/tsocket/tsocket.h
@@ -897,12 +897,12 @@ struct sockaddr;
  * @return              0 on success, -1 on error with errno set.
  */
 int tsocket_address_bsd_from_sockaddr(TALLOC_CTX *mem_ctx,
-                                     struct sockaddr *sa,
+                                     const struct sockaddr *sa,
                                      size_t sa_socklen,
                                      struct tsocket_address **addr);
 #else
 int _tsocket_address_bsd_from_sockaddr(TALLOC_CTX *mem_ctx,
-                                      struct sockaddr *sa,
+                                      const struct sockaddr *sa,
                                       size_t sa_socklen,
                                       struct tsocket_address **_addr,
                                       const char *location);
diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c
index 89e5f4c..4417f8e 100644
--- a/lib/tsocket/tsocket_bsd.c
+++ b/lib/tsocket/tsocket_bsd.c
@@ -209,7 +209,7 @@ struct tsocket_address_bsd {
 };
 
 int _tsocket_address_bsd_from_sockaddr(TALLOC_CTX *mem_ctx,
-                                      struct sockaddr *sa,
+                                      const struct sockaddr *sa,
                                       size_t sa_socklen,
                                       struct tsocket_address **_addr,
                                       const char *location)
diff --git a/librpc/rpc/binding_handle.c b/librpc/rpc/binding_handle.c
index 89ada1d..9354bbd 100644
--- a/librpc/rpc/binding_handle.c
+++ b/librpc/rpc/binding_handle.c
@@ -515,7 +515,7 @@ NTSTATUS dcerpc_binding_handle_call(struct 
dcerpc_binding_handle *h,
        TALLOC_CTX *frame = talloc_stackframe();
        struct tevent_context *ev;
        struct tevent_req *subreq;
-       NTSTATUS status;
+       NTSTATUS status = NT_STATUS_NO_MEMORY;
 
        /*
         * TODO: allow only one sync call
@@ -527,30 +527,22 @@ NTSTATUS dcerpc_binding_handle_call(struct 
dcerpc_binding_handle *h,
                ev = samba_tevent_context_init(frame);
        }
        if (ev == NULL) {
-               talloc_free(frame);
-               return NT_STATUS_NO_MEMORY;
+               goto fail;
        }
 
        subreq = dcerpc_binding_handle_call_send(frame, ev,
                                                 h, object, table,
                                                 opnum, r_mem, r_ptr);
        if (subreq == NULL) {
-               talloc_free(frame);
-               return NT_STATUS_NO_MEMORY;
+               goto fail;
        }
 
-       if (!tevent_req_poll(subreq, ev)) {
-               status = map_nt_error_from_unix_common(errno);
-               talloc_free(frame);
-               return status;
+       if (!tevent_req_poll_ntstatus(subreq, ev, &status)) {
+               goto fail;
        }
 
        status = dcerpc_binding_handle_call_recv(subreq);
-       if (!NT_STATUS_IS_OK(status)) {
-               talloc_free(frame);
-               return status;
-       }
-
+fail:
        TALLOC_FREE(frame);
-       return NT_STATUS_OK;
+       return status;
 }
diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h
index 5846e9b..137aebe 100644
--- a/source3/include/libsmbclient.h
+++ b/source3/include/libsmbclient.h
@@ -276,9 +276,9 @@ typedef struct _SMBCCTX SMBCCTX;
 
 /**@ingroup callback
  * Authentication callback function type (traditional method)
- * 
+ *
  * Type for the the authentication function called by the library to
- * obtain authentication credentals
+ * obtain authentication credentials
  *
  * For kerberos support the function should just be called without
  * prompting the user for credentials. Which means a simple 'return'
@@ -315,9 +315,9 @@ typedef void (*smbc_get_auth_data_fn)(const char *srv,
                                       char *pw, int pwlen);
 /**@ingroup callback
  * Authentication callback function type (method that includes context)
- * 
+ *
  * Type for the the authentication function called by the library to
- * obtain authentication credentals
+ * obtain authentication credentials
  *
  * For kerberos support the function should just be called without
  * prompting the user for credentials. Which means a simple 'return'
diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c
index 8ace4d9..08adf21 100644
--- a/source3/lib/gencache.c
+++ b/source3/lib/gencache.c
@@ -58,7 +58,6 @@ static bool gencache_init(void)
 {
        char* cache_fname = NULL;
        int open_flags = O_RDWR|O_CREAT;
-       bool first_try = true;
 
        /* skip file open if it's already opened */
        if (cache) return True;
@@ -67,24 +66,28 @@ static bool gencache_init(void)
 
        DEBUG(5, ("Opening cache file at %s\n", cache_fname));
 
-again:
        cache = tdb_open_log(cache_fname, 0, TDB_DEFAULT|TDB_INCOMPATIBLE_HASH, 
open_flags, 0644);
        if (cache) {
                int ret;
                ret = tdb_check(cache, NULL, NULL);
                if (ret != 0) {
                        tdb_close(cache);
-                       cache = NULL;
-                       if (!first_try) {
-                               DEBUG(0, ("gencache_init: tdb_check(%s) 
failed\n",
-                                         cache_fname));
-                               return false;
-                       }
-                       first_try = false;
-                       DEBUG(0, ("gencache_init: tdb_check(%s) failed - retry 
after truncate\n",
-                                 cache_fname));
-                       truncate(cache_fname, 0);
-                       goto again;
+
+                       /*
+                        * Retry with CLEAR_IF_FIRST.
+                        *
+                        * Warning: Converting this to dbwrap won't work
+                        * directly. gencache.c does transactions on this tdb,
+                        * and dbwrap forbids this for CLEAR_IF_FIRST
+                        * databases. tdb does allow transactions on
+                        * CLEAR_IF_FIRST databases, so lets use it here to
+                        * clean up a broken database.
+                        */
+                       cache = tdb_open_log(cache_fname, 0,
+                                            TDB_DEFAULT|
+                                            TDB_INCOMPATIBLE_HASH|
+                                            TDB_CLEAR_IF_FIRST,
+                                            open_flags, 0644);
                }
        }
 


-- 
Samba Shared Repository

Reply via email to