[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Fri Jun 12 11:56:03 MDT 2015


The branch, master has been updated
       via  4ddf78a tdb: version 1.3.6
       via  89dcfbf lib/replace: remove unused HAVE_DECL_PTHREAD_{MUTEXATTR_SETROBUST,MUTEX_CONSISTENT}_NP checks
       via  34cf1d2 lib/replace: fix PTHREAD_MUTEX_ROBUST fallback to PTHREAD_MUTEX_ROBUST_NP on solaris 11
       via  ff072a6 wafsamba: let CHECK_DECLS() find enum values
       via  86671db wafsamba: remove unused allow_warnings=True from SAMBA_PYTHON()
       via  70737dd s3:pysmbd: #include <Python.h> must be the first include in order to avoid compiler warnings
       via  cf7e1c7 pidl:NDR/Parser: check [ref] pointers before pushing anything else
       via  3c97bfe pidl:NDR/Parser: protect for loops against $length being an expression instead of a scalar variable
       via  781cc3d pidl:Python: protect for loops against $length being an expression instead of a scalar variable
       via  ad7148f pidl:Python: use discard_const() to pass a possible const pointer to talloc_unlink()
       via  3d7ce9d s4:ntvfs/pyposix_eadb: fix initposix_eadb() prototype
       via  d7bdb30 tevent: version 0.9.25
       via  93ee074 pytevent: add a TeventTimer_Object_ref helper structure to make the code clearer
       via  fb04f0f pytevent: remove const warnings using discard_const_p()
       via  1a8a5ba pytevent: remove dead code TEVENT_DEPRECATED is never defined
       via  2216141 talloc:guide: fix documented signature of talloc_unlink().
       via  66e96d9 talloc:manpage: fix documented signature of talloc_unlink().
       via  f5d74c2 talloc: sync the talloc_reference() description between talloc_guide and manpage
       via  1898200 ctdb-vacuum: revert "Do not delete VACUUM MIGRATED records immediately"
       via  53ff3e4 ctdb-ib: make sure the tevent_fd is removed before the fd is closed
       via  006042a libcli/smb: make sure we remove the writev_send() request when a request is destroyed
       via  f3982eb libcli/smb: add smb1 requests to the pending array before writev_send()
       via  5933843 libcli/smb: make sure the writev_send of smbXcli_conn_samba_suicide() is removed before closing the socket
       via  8f42df2 libcli/smb: remove unused split of read_fd and write_fd
       via  46e1aa2 libcli/smb: close the socket fd at the end of smbXcli_conn_disconnect()
       via  26c4b3f libcli/smb: use tevent_req_received(req) in read_smb_recv()
       via  64640cc lib/async_req: remove the tevent_fd as early as possible via a wait_for_read_cleanup() hook
       via  a2a7cbc lib/async_req: remove the tevent_fd as early as possible via a read_packet_cleanup() hook
       via  9a116b2 lib/async_req: use tevent_req_nomem/tevent_req_post in read_packet_send()
       via  4f05f68 lib/async_req: s/result/req/ in read_packet_send()
       via  0c11096 lib/async_req: remove the tevent_fd as early as possible via a writev_cleanup() hook
       via  d5a4b30 lib/async_req: simplify async_connect_* using a _cleanup() hook
       via  be8c2ff lib/async_req: s/result/req/ in async_connect_send()
       via  ccd038e lib/async_req: remove unused sendto_{send,recv} and recvfrom_{send,recv}
       via  a328291 s3:libsmb: convert nb_trans_send/recv internals to tdgram
       via  ecb4d04 s3:libsmb: convert nb_packet_reader to tstream_* functions
       via  3ecf4ec s3:libsmb: convert nb_packet_client to tstream_* functions
       via  9ccf8e6 s3:libsmb: let nb_packet_server_destructor() explicitly destroy the tevent_fd
       via  058d847 s3:libsmb: remove pending requests as early as possible via a smbsock_any_connect_cleanup() hook
       via  04f89d4 s3:libsmb: remove subreqs as early as possible via a smbsock_connect_cleanup() hook
       via  992be06 s3:libsmb: remove the cli_session_request as early as possible via a nb_connect_cleanup() hook
       via  0d161e4 s3:lib/addrchange: make use of tdgram_* in addrchange_*()
       via  257bc58 s3:lib/addrchange: look at the correct nl_pid in addrchange_done()
       via  9d3444a s3:lib/background: make sure we destroy a pending read_packet_send() before closing the pipe fd
       via  0c108f5 s3:wscript: move lib/util_tsock.c from 'TLDAP' to 'samba3util'
       via  dd037b0 s4:libcli/raw: make sure smbcli_transport_connect_send/recv correctly cleanup on error
       via  36b97d0 lib/tsocket: add tdgram_inet_udp_broadcast_socket()
       via  3a8b7b0 lib/tsocket: add tdgram_bsd_existing_socket() helper function
       via  44584f8 tevent.h: propose tstream_ versions of read_packet_send/recv and writev_send/recv
       via  88971d4 tevent/testsuite: make sure we cleanup tevent_fd structures in the correct order
      from  b3a18d6 ctdb-locking: move all auto_mark logic into process_callbacks()

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


- Log -----------------------------------------------------------------
commit 4ddf78a282c85e84b6201a79b707fad9487f3ccd
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jun 12 09:10:39 2015 +0200

    tdb: version 1.3.6
    
    * Fix runtime detection for robust mutexes in the standalone build.
      bug #11326
    * Possible fix for the build with robust mutexes on solaris 11
      bug #11319
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Fri Jun 12 19:55:34 CEST 2015 on sn-devel-104

commit 89dcfbf3f45f448e515a1da82e09002a0aafb7b4
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jun 12 11:01:21 2015 +0200

    lib/replace: remove unused HAVE_DECL_PTHREAD_{MUTEXATTR_SETROBUST,MUTEX_CONSISTENT}_NP checks
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11319
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 34cf1d213ec0261af41ef6a16f5b37e5015c614b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jun 12 11:01:21 2015 +0200

    lib/replace: fix PTHREAD_MUTEX_ROBUST fallback to PTHREAD_MUTEX_ROBUST_NP on solaris 11
    
    Without this we got the following defines in config.h:
    
       #define HAVE_DECL_PTHREAD_MUTEXATTR_SETROBUST_NP 1
       #define HAVE_DECL_PTHREAD_MUTEX_CONSISTENT_NP 1
       #define HAVE_PTHREAD_MUTEXATTR_SETROBUST 1
       #define HAVE_PTHREAD_MUTEX_CONSISTENT 1
       #define HAVE_ROBUST_MUTEXES 1
       #define USE_TDB_MUTEX_LOCKING 1
    
    And the build failed with PTHREAD_MUTEX_ROBUST being unknown.
    
    Note that PTHREAD_MUTEX_ROBUST and PTHREAD_MUTEX_ROBUST_NP are enum values
    while they're defines on solaris 11
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11319
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit ff072a633660780cf72d204f4620c664957a6072
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jun 12 12:13:23 2015 +0200

    wafsamba: let CHECK_DECLS() find enum values
    
    In the current state this still generates the same config.h
    at least on ubuntu 14.04 amd64.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 86671dbd9f912e27be3ff7ba3a5f9b8200bf2550
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jun 11 10:01:15 2015 +0200

    wafsamba: remove unused allow_warnings=True from SAMBA_PYTHON()
    
    This is not needed anymore all python bindings build without wawrnings now.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 70737dd5512df3838e985137715352930ee438df
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jun 12 11:45:39 2015 +0200

    s3:pysmbd: #include <Python.h> must be the first include in order to avoid compiler warnings
    
    This is the only exception, normally "replace.h" or "includes.h" need to be the
    first include.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit cf7e1c7597dac52c4efd37da1d8130899bfd7509
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jun 11 09:01:24 2015 +0200

    pidl:NDR/Parser: check [ref] pointers before pushing anything else
    
    This was reported by Coverity as
    CID 1288527:  Null pointer dereferences  (REVERSE_INULL)
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 3c97bfe9de538d9f551f2c3d77ee3ab820a39b4a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jun 11 08:54:11 2015 +0200

    pidl:NDR/Parser: protect for loops against $length being an expression instead of a scalar variable
    
    This changes
    
    for (value_cntr_1 = 0; value_cntr_1 < r->out.length?*r->out.length:0; value_cntr_1++) {
    
    into:
    
    for (value_cntr_1 = 0; value_cntr_1 < (r->out.length?*r->out.length:0); value_cntr_1++) {
    
    it fixes a possible endless loop resulting in a crash.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 781cc3d50f18e69bad5faf67ee46f7b1fd28cf2a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jun 11 08:54:11 2015 +0200

    pidl:Python: protect for loops against $length being an expression instead of a scalar variable
    
    This changes
    
    for (value_cntr_1 = 0; value_cntr_1 < r->out.length?*r->out.length:0; value_cntr_1++) {
    
    into:
    
    for (value_cntr_1 = 0; value_cntr_1 < (r->out.length?*r->out.length:0); value_cntr_1++) {
    
    it fixes a possible endless loop resulting in a crash.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit ad7148fec650c10fa77daf73ece57a8dfa37eb63
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jun 11 09:58:13 2015 +0200

    pidl:Python: use discard_const() to pass a possible const pointer to talloc_unlink()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 3d7ce9d411d720c975f868386498da3db4f07d53
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jun 11 09:57:23 2015 +0200

    s4:ntvfs/pyposix_eadb: fix initposix_eadb() prototype
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit d7bdb30cc1731dc84831e323332a85be2bccf6a7
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jun 12 08:58:26 2015 +0200

    tevent: version 0.9.25
    
    * Fix compile error in Solaris ports backend.
    * Fix access after free in tevent_common_check_signal(). bug #11308
    * Improve pytevent bindings.
    * Testsuite fixes.
    * Improve the documentation of the tevent_add_fd()
      assumtions. It must be talloc_free'ed before closing the fd!
      See bug #11141 and bug #11316.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 93ee074f912da02d4c1f1584df9b107364b639be
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jun 11 09:51:19 2015 +0200

    pytevent: add a TeventTimer_Object_ref helper structure to make the code clearer
    
    This gives talloc_set_destructor to verify the type,
    which removes a compiler warning.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit fb04f0f4190005ff21817b79d02897af23ddc7ee
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jun 11 09:50:35 2015 +0200

    pytevent: remove const warnings using discard_const_p()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 1a8a5ba0d51f9c2c9e84a3400e05327e7059156b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jun 11 09:49:18 2015 +0200

    pytevent: remove dead code TEVENT_DEPRECATED is never defined
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 2216141ff8a204c8b41293a19e9ce86308b0424f
Author: Michael Adam <obnox at samba.org>
Date:   Fri Jun 12 10:23:41 2015 +0200

    talloc:guide: fix documented signature of talloc_unlink().
    
    The second argument is void *, not const void *.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 66e96d9ac6b244c8cd4a95205d5576d78b22dfcd
Author: Michael Adam <obnox at samba.org>
Date:   Fri Jun 12 10:16:40 2015 +0200

    talloc:manpage: fix documented signature of talloc_unlink().
    
    The second argument is void *, not const void *.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit f5d74c26a397b2d80d26e2bcf11e0574d3fa995c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jun 11 16:39:35 2015 +0200

    talloc: sync the talloc_reference() description between talloc_guide and manpage
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 1898200481f64676e596e52dc177c8d70ca1a00c
Author: Michael Adam <obnox at samba.org>
Date:   Fri Jun 12 10:59:54 2015 +0200

    ctdb-vacuum: revert "Do not delete VACUUM MIGRATED records immediately"
    
    This reverts commit 257311e337065f089df688cbf261d2577949203d.
    
    That commit was due to a misunderstanding, and it
    does not fix what it was supposed to fix.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 53ff3e4f31f3debd98f9293171c023a0a406858d
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jun 5 10:30:39 2015 +0200

    ctdb-ib: make sure the tevent_fd is removed before the fd is closed
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 006042ac126261e87089fb9835c28789e8aeae1b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 29 16:14:40 2015 +0200

    libcli/smb: make sure we remove the writev_send() request when a request is destroyed
    
    This way smbXcli_conn_disconnect() removes all tevent_fd structures attached to
    the sock_fd before closing it.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit f3982eb2c7f1d17a013dacfd430a3752e6ef4ae4
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 29 15:48:26 2015 +0200

    libcli/smb: add smb1 requests to the pending array before writev_send()
    
    This way we have a change to destroy the pending writev_send request before
    closing the socket in smbXcli_conn_disconnect().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 59338434274799db1ac60b082a6453bd924c5f4c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 29 15:29:31 2015 +0200

    libcli/smb: make sure the writev_send of smbXcli_conn_samba_suicide() is removed before closing the socket
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 8f42df235dc825a103631fdf0e37e1c1d03cf420
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 28 13:22:19 2015 +0200

    libcli/smb: remove unused split of read_fd and write_fd
    
    The tevent epoll backend supports separate read and write tevent_fd structure
    on a single fd, so there's no need for a dup() anymore.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 46e1aa22b12eacc3567f7897716ae07837545c23
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 28 13:09:11 2015 +0200

    libcli/smb: close the socket fd at the end of smbXcli_conn_disconnect()
    
    We need to cancel all pending requests before closing the socket fds,
    otherwise we cause problem with the interaction with the epoll event backend.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 26c4b3fc9db507557b2539dd7d1f9e593c3fa35a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 22:29:55 2015 +0200

    libcli/smb: use tevent_req_received(req) in read_smb_recv()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 64640cc99c7b8543ee8d35ca243c57c048cdb490
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 22:28:14 2015 +0200

    lib/async_req: remove the tevent_fd as early as possible via a wait_for_read_cleanup() hook
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit a2a7cbc66c4713493e6ade45d0cdde25f64c9007
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 22:28:14 2015 +0200

    lib/async_req: remove the tevent_fd as early as possible via a read_packet_cleanup() hook
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 9a116b28bab20507760f50f25214635a60ea6c43
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 22:28:14 2015 +0200

    lib/async_req: use tevent_req_nomem/tevent_req_post in read_packet_send()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 4f05f68abc1d756bb114260e80d3532f3f959fec
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 22:28:14 2015 +0200

    lib/async_req: s/result/req/ in read_packet_send()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 0c1109695639a177d3d739b343e7588a6ecf0949
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 22:28:14 2015 +0200

    lib/async_req: remove the tevent_fd as early as possible via a writev_cleanup() hook
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit d5a4b30f894f0d4d4fa728ebd2c435254bf3b142
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 22:28:14 2015 +0200

    lib/async_req: simplify async_connect_* using a _cleanup() hook
    
    This makes sure we remove the tevent_fd as soon as possible
    and always reset the old_sockflags.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit be8c2ff10353df00f05cd378c251a33a9e08563a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jun 5 13:58:19 2015 +0200

    lib/async_req: s/result/req/ in async_connect_send()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit ccd038e1523a69197a9aaeca00305b0958f09ff0
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 12:25:38 2015 +0200

    lib/async_req: remove unused sendto_{send,recv} and recvfrom_{send,recv}
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit a3282911f6ceb76b2ada567e569a55af8c7ef160
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 04:43:27 2015 +0200

    s3:libsmb: convert nb_trans_send/recv internals to tdgram
    
    This simplifies/fixes the cleanup, because we need to remove any
    tevent_fd object before closing the socket fd.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit ecb4d041de89441941a112ab3a724887e568117e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 02:18:26 2015 +0200

    s3:libsmb: convert nb_packet_reader to tstream_* functions
    
    By using the tstream abstraction we don't need to take care
    error handling regarding dangling tevent_fd structures.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 3ecf4ec6574de9bdd5a2d55529ed81b17c74d452
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 01:53:44 2015 +0200

    s3:libsmb: convert nb_packet_client to tstream_* functions
    
    By using the tstream abstraction we don't need to take care
    error handling regarding dangling tevent_fd structures.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 9ccf8e6d36618498c4952bb1d4b74152f75ab793
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 02:20:00 2015 +0200

    s3:libsmb: let nb_packet_server_destructor() explicitly destroy the tevent_fd
    
    The need to destroy the tevent_fd before closing the socket fd.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 058d84747e75a5f97a02e31bac9c8d0d147174bc
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 03:01:30 2015 +0200

    s3:libsmb: remove pending requests as early as possible via a smbsock_any_connect_cleanup() hook
    
    Once we got an error or a valid connection we should destroy all other
    connection attempts as early as possible.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 04f89d4255ed95631aa8f0ada4bcf5f888e126d4
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 03:01:05 2015 +0200

    s3:libsmb: remove subreqs as early as possible via a smbsock_connect_cleanup() hook
    
    open_socket_out_send() or nb_connect_send() likely use socket fds and
    tevent_fd objects. We should clean them up as early as possible.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 992be06f165c3d05e85d16baf514dba49f55d1ec
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 03:00:17 2015 +0200

    s3:libsmb: remove the cli_session_request as early as possible via a nb_connect_cleanup() hook
    
    cli_session_request_send() is likely to use tevent_fd objects on the given
    socket fd, so we need to destroy the request before closing the socket fd.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 0d161e42d9aeb155eae2b04eccec497b21de8029
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 12:17:24 2015 +0200

    s3:lib/addrchange: make use of tdgram_* in addrchange_*()
    
    This makes the cleanup handling easier to get right,
    as we need to make sure any tevent_fd is removed before
    closing a socket fd.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 257bc586c22f9a7f34b913823d5c89592d433454
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jun 5 14:19:00 2015 +0200

    s3:lib/addrchange: look at the correct nl_pid in addrchange_done()
    
    state->fromaddr is the address we got from recvfrom_send/recv.
    
    state->addr is completely untouched after tevent_req_create().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 9d3444ad887bb3a118eaecd141c79dfd6de53f41
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 28 13:31:17 2015 +0200

    s3:lib/background: make sure we destroy a pending read_packet_send() before closing the pipe fd
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 0c108f55d9c3cca0bde1c15c66dccabbc40e6133
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 03:45:36 2015 +0200

    s3:wscript: move lib/util_tsock.c from 'TLDAP' to 'samba3util'
    
    tstream_read_packet_send/recv() is a generic helper function...
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit dd037b0be4ed2df7239cb61bd3d4bb868bb09126
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 28 14:25:27 2015 +0200

    s4:libcli/raw: make sure smbcli_transport_connect_send/recv correctly cleanup on error
    
    We need to make sure that we remove any pending writev_send or read_smb_send
    request before closing the socket fd. As a side effect we always close the
    socket fd if we don't return success for any any reason.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 36b97d0bb9fe004f3d8a500f3af83dff34f86d7b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 11:39:38 2015 +0200

    lib/tsocket: add tdgram_inet_udp_broadcast_socket()
    
    This is similar to tdgram_inet_udp_socket(), but it allows
    the use of ipv4 broadcast traffic.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3a8b7b0518b33b016d2dbb8dd23d35ef1c6aaa5c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 11:37:06 2015 +0200

    lib/tsocket: add tdgram_bsd_existing_socket() helper function
    
    This is similar to tstream_bsd_existing_socket().
    Both help to migrate strange code path to using the tstream or tdgram
    abstractions.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 44584f810720602201a9afaaa087eeb83579eff5
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 28 09:32:26 2015 +0200

    tevent.h: propose tstream_ versions of read_packet_send/recv and writev_send/recv
    
    The functions operating on the raw file descriptor are for advanced callers,
    which take extra care and avoid the problems of
    https://bugzilla.samba.org/show_bug.cgi?id=11141.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 88971d4870a197f656ef912911ca1e4ff5b56749
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat May 30 01:42:08 2015 +0200

    tevent/testsuite: make sure we cleanup tevent_fd structures in the correct order
    
    First we need to remove the tevent_fd structures without
    tevent_fd_set_auto_close(). Closing the fd needs to be the last
    thing...
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 buildtools/wafsamba/samba_autoconf.py              |  13 +-
 buildtools/wafsamba/samba_python.py                |   1 -
 ctdb/ib/ibwrapper.c                                |  21 +-
 ctdb/server/ctdb_ltdb_server.c                     |   5 -
 lib/async_req/async_sock.c                         | 369 +++++++--------------
 lib/async_req/async_sock.h                         |  12 -
 lib/replace/system/threads.h                       |   9 +-
 lib/replace/wscript                                |  14 +-
 lib/talloc/man/talloc.3.xml                        |   8 +-
 lib/talloc/talloc_guide.txt                        |   2 +-
 lib/tdb/ABI/{tdb-1.3.5.sigs => tdb-1.3.6.sigs}     |   0
 lib/tdb/wscript                                    |   2 +-
 .../ABI/{tevent-0.9.21.sigs => tevent-0.9.25.sigs} |   0
 lib/tevent/pytevent.c                              | 106 ++----
 lib/tevent/testsuite.c                             |   4 +-
 lib/tevent/tevent.h                                |   4 +-
 lib/tevent/wscript                                 |   2 +-
 lib/tsocket/tsocket.h                              |  71 ++++
 lib/tsocket/tsocket_bsd.c                          |  54 +++
 libcli/smb/read_smb.c                              |   2 +
 libcli/smb/smbXcli_base.c                          | 124 ++++---
 pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm           |  62 +++-
 pidl/lib/Parse/Pidl/Samba4/Python.pm               |   4 +-
 source3/lib/addrchange.c                           |  91 +++--
 source3/lib/background.c                           |   8 +
 source3/libsmb/namequery.c                         | 102 ++++--
 source3/libsmb/smbsock_connect.c                   | 101 +++++-
 source3/libsmb/unexpected.c                        | 203 ++++++------
 source3/smbd/pysmbd.c                              |   2 +-
 source3/wscript_build                              |   9 +-
 source4/libcli/raw/clisocket.c                     |  59 +++-
 source4/ntvfs/posix/python/pyposix_eadb.c          |   2 +-
 32 files changed, 831 insertions(+), 635 deletions(-)
 copy lib/tdb/ABI/{tdb-1.3.5.sigs => tdb-1.3.6.sigs} (100%)
 copy lib/tevent/ABI/{tevent-0.9.21.sigs => tevent-0.9.25.sigs} (100%)


Changeset truncated at 500 lines:

diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index 4f646fd..c5f132c 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -229,7 +229,18 @@ def CHECK_DECLS(conf, vars, reverse=False, headers=None, always=False):
                               headers=headers,
                               msg='Checking for declaration of %s' % v,
                               always=always):
-            ret = False
+            if not CHECK_CODE(conf,
+                      '''
+                      return (int)%s;
+                      ''' % (v),
+                      execute=False,
+                      link=False,
+                      msg='Checking for declaration of %s (as enum)' % v,
+                      local_include=False,
+                      headers=headers,
+                      define=define,
+                      always=always):
+                ret = False
     return ret
 
 
diff --git a/buildtools/wafsamba/samba_python.py b/buildtools/wafsamba/samba_python.py
index 8b20066..fb378ae 100644
--- a/buildtools/wafsamba/samba_python.py
+++ b/buildtools/wafsamba/samba_python.py
@@ -109,7 +109,6 @@ def SAMBA_PYTHON(bld, name,
                       target_type='PYTHON',
                       install_path='${PYTHONARCHDIR}',
                       allow_undefined_symbols=True,
-                      allow_warnings=True,
                       install=install,
                       enabled=enabled)
 
diff --git a/ctdb/ib/ibwrapper.c b/ctdb/ib/ibwrapper.c
index 3daab3e..51d39da 100644
--- a/ctdb/ib/ibwrapper.c
+++ b/ctdb/ib/ibwrapper.c
@@ -134,16 +134,16 @@ static int ibw_ctx_priv_destruct(struct ibw_ctx_priv *pctx)
 {
 	DEBUG(DEBUG_DEBUG, ("ibw_ctx_priv_destruct(%p)\n", pctx));
 
+	/*
+	 * tevent_fd must be removed before the fd is closed
+	 */
+	TALLOC_FREE(pctx->cm_channel_event);
+
 	/* destroy cm */
 	if (pctx->cm_channel) {
 		rdma_destroy_event_channel(pctx->cm_channel);
 		pctx->cm_channel = NULL;
 	}
-	if (pctx->cm_channel_event) {
-		/* TODO: do we have to do this here? */
-		talloc_free(pctx->cm_channel_event);
-		pctx->cm_channel_event = NULL;
-	}
 	if (pctx->cm_id) {
 		rdma_destroy_id(pctx->cm_id);
 		pctx->cm_id = NULL;
@@ -166,6 +166,11 @@ static int ibw_conn_priv_destruct(struct ibw_conn_priv *pconn)
 	/* pconn->wr_index is freed by talloc */
 	/* pconn->wr_index[i] are freed by talloc */
 
+	/*
+	 * tevent_fd must be removed before the fd is closed
+	 */
+	TALLOC_FREE(pconn->verbs_channel_event);
+
 	/* destroy verbs */
 	if (pconn->cm_id!=NULL && pconn->cm_id->qp!=NULL) {
 		rdma_destroy_qp(pconn->cm_id);
@@ -182,12 +187,6 @@ static int ibw_conn_priv_destruct(struct ibw_conn_priv *pconn)
 		pconn->verbs_channel = NULL;
 	}
 
-	/* must be freed here because its order is important */
-	if (pconn->verbs_channel_event) {
-		talloc_free(pconn->verbs_channel_event);
-		pconn->verbs_channel_event = NULL;
-	}
-
 	/* free memory regions */
 	ibw_free_mr(&pconn->buf_send, &pconn->mr_send);
 	ibw_free_mr(&pconn->buf_recv, &pconn->mr_recv);
diff --git a/ctdb/server/ctdb_ltdb_server.c b/ctdb/server/ctdb_ltdb_server.c
index 8cf7180..c94e1d5 100644
--- a/ctdb/server/ctdb_ltdb_server.c
+++ b/ctdb/server/ctdb_ltdb_server.c
@@ -115,11 +115,6 @@ static int ctdb_ltdb_store_server(struct ctdb_db_context *ctdb_db,
 		 * fails. So storing the empty record makes sure that we do not
 		 * need to change the client code.
 		 */
-		if ((header->flags & CTDB_REC_FLAG_VACUUM_MIGRATED) &&
-		    (ctdb_db->ctdb->pnn == header->dmaster)) {
-			keep = true;
-			schedule_for_deletion = true;
-		}
 		if (!(header->flags & CTDB_REC_FLAG_VACUUM_MIGRATED)) {
 			keep = true;
 		} else if (ctdb_db->ctdb->pnn != header->dmaster) {
diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c
index ee91b8f..03bda58 100644
--- a/lib/async_req/async_sock.c
+++ b/lib/async_req/async_sock.c
@@ -33,188 +33,10 @@
 #include "lib/util/tevent_unix.h"
 #include "lib/util/samba_util.h"
 
-#ifndef TALLOC_FREE
-#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0)
-#endif
-
-struct sendto_state {
-	int fd;
-	const void *buf;
-	size_t len;
-	int flags;
-	const struct sockaddr_storage *addr;
-	socklen_t addr_len;
-	ssize_t sent;
-};
-
-static void sendto_handler(struct tevent_context *ev,
-			       struct tevent_fd *fde,
-			       uint16_t flags, void *private_data);
-
-struct tevent_req *sendto_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-			       int fd, const void *buf, size_t len, int flags,
-			       const struct sockaddr_storage *addr)
-{
-	struct tevent_req *result;
-	struct sendto_state *state;
-	struct tevent_fd *fde;
-
-	result = tevent_req_create(mem_ctx, &state, struct sendto_state);
-	if (result == NULL) {
-		return result;
-	}
-	state->fd = fd;
-	state->buf = buf;
-	state->len = len;
-	state->flags = flags;
-	state->addr = addr;
-
-	switch (addr->ss_family) {
-	case AF_INET:
-		state->addr_len = sizeof(struct sockaddr_in);
-		break;
-#if defined(HAVE_IPV6)
-	case AF_INET6:
-		state->addr_len = sizeof(struct sockaddr_in6);
-		break;
-#endif
-	case AF_UNIX:
-		state->addr_len = sizeof(struct sockaddr_un);
-		break;
-	default:
-		state->addr_len = sizeof(struct sockaddr_storage);
-		break;
-	}
-
-	fde = tevent_add_fd(ev, state, fd, TEVENT_FD_WRITE, sendto_handler,
-			    result);
-	if (fde == NULL) {
-		TALLOC_FREE(result);
-		return NULL;
-	}
-	return result;
-}
-
-static void sendto_handler(struct tevent_context *ev,
-			       struct tevent_fd *fde,
-			       uint16_t flags, void *private_data)
-{
-	struct tevent_req *req = talloc_get_type_abort(
-		private_data, struct tevent_req);
-	struct sendto_state *state =
-		tevent_req_data(req, struct sendto_state);
-
-	state->sent = sendto(state->fd, state->buf, state->len, state->flags,
-			     (const struct sockaddr *)state->addr,
-			     state->addr_len);
-	if ((state->sent == -1) && (errno == EINTR)) {
-		/* retry */
-		return;
-	}
-	if (state->sent == -1) {
-		tevent_req_error(req, errno);
-		return;
-	}
-	tevent_req_done(req);
-}
-
-ssize_t sendto_recv(struct tevent_req *req, int *perrno)
-{
-	struct sendto_state *state =
-		tevent_req_data(req, struct sendto_state);
-
-	if (tevent_req_is_unix_error(req, perrno)) {
-		return -1;
-	}
-	return state->sent;
-}
-
-struct recvfrom_state {
-	int fd;
-	void *buf;
-	size_t len;
-	int flags;
-	struct sockaddr_storage *addr;
-	socklen_t *addr_len;
-	ssize_t received;
-};
-
-static void recvfrom_handler(struct tevent_context *ev,
-			       struct tevent_fd *fde,
-			       uint16_t flags, void *private_data);
-
-struct tevent_req *recvfrom_send(TALLOC_CTX *mem_ctx,
-				 struct tevent_context *ev,
-				 int fd, void *buf, size_t len, int flags,
-				 struct sockaddr_storage *addr,
-				 socklen_t *addr_len)
-{
-	struct tevent_req *result;
-	struct recvfrom_state *state;
-	struct tevent_fd *fde;
-
-	result = tevent_req_create(mem_ctx, &state, struct recvfrom_state);
-	if (result == NULL) {
-		return result;
-	}
-	state->fd = fd;
-	state->buf = buf;
-	state->len = len;
-	state->flags = flags;
-	state->addr = addr;
-	state->addr_len = addr_len;
-
-	fde = tevent_add_fd(ev, state, fd, TEVENT_FD_READ, recvfrom_handler,
-			    result);
-	if (fde == NULL) {
-		TALLOC_FREE(result);
-		return NULL;
-	}
-	return result;
-}
-
-static void recvfrom_handler(struct tevent_context *ev,
-			       struct tevent_fd *fde,
-			       uint16_t flags, void *private_data)
-{
-	struct tevent_req *req = talloc_get_type_abort(
-		private_data, struct tevent_req);
-	struct recvfrom_state *state =
-		tevent_req_data(req, struct recvfrom_state);
-
-	state->received = recvfrom(state->fd, state->buf, state->len,
-				   state->flags, (struct sockaddr *)state->addr,
-				   state->addr_len);
-	if ((state->received == -1) && (errno == EINTR)) {
-		/* retry */
-		return;
-	}
-	if (state->received == 0) {
-		tevent_req_error(req, EPIPE);
-		return;
-	}
-	if (state->received == -1) {
-		tevent_req_error(req, errno);
-		return;
-	}
-	tevent_req_done(req);
-}
-
-ssize_t recvfrom_recv(struct tevent_req *req, int *perrno)
-{
-	struct recvfrom_state *state =
-		tevent_req_data(req, struct recvfrom_state);
-
-	if (tevent_req_is_unix_error(req, perrno)) {
-		return -1;
-	}
-	return state->received;
-}
-
 struct async_connect_state {
 	int fd;
+	struct tevent_fd *fde;
 	int result;
-	int sys_errno;
 	long old_sockflags;
 	socklen_t address_len;
 	struct sockaddr_storage address;
@@ -224,6 +46,8 @@ struct async_connect_state {
 	void *private_data;
 };
 
+static void async_connect_cleanup(struct tevent_req *req,
+				  enum tevent_req_state req_state);
 static void async_connect_connected(struct tevent_context *ev,
 				    struct tevent_fd *fde, uint16_t flags,
 				    void *priv);
@@ -248,13 +72,11 @@ struct tevent_req *async_connect_send(
 	void (*after_connect)(void *private_data),
 	void *private_data)
 {
-	struct tevent_req *result;
+	struct tevent_req *req;
 	struct async_connect_state *state;
-	struct tevent_fd *fde;
 
-	result = tevent_req_create(
-		mem_ctx, &state, struct async_connect_state);
-	if (result == NULL) {
+	req = tevent_req_create(mem_ctx, &state, struct async_connect_state);
+	if (req == NULL) {
 		return NULL;
 	}
 
@@ -264,20 +86,22 @@ struct tevent_req *async_connect_send(
 	 */
 
 	state->fd = fd;
-	state->sys_errno = 0;
 	state->before_connect = before_connect;
 	state->after_connect = after_connect;
 	state->private_data = private_data;
 
 	state->old_sockflags = fcntl(fd, F_GETFL, 0);
 	if (state->old_sockflags == -1) {
-		goto post_errno;
+		tevent_req_error(req, errno);
+		return tevent_req_post(req, ev);
 	}
 
+	tevent_req_set_cleanup_fn(req, async_connect_cleanup);
+
 	state->address_len = address_len;
 	if (address_len > sizeof(state->address)) {
-		errno = EINVAL;
-		goto post_errno;
+		tevent_req_error(req, EINVAL);
+		return tevent_req_post(req, ev);
 	}
 	memcpy(&state->address, address, address_len);
 
@@ -294,8 +118,8 @@ struct tevent_req *async_connect_send(
 	}
 
 	if (state->result == 0) {
-		tevent_req_done(result);
-		goto done;
+		tevent_req_done(req);
+		return tevent_req_post(req, ev);
 	}
 
 	/**
@@ -310,23 +134,31 @@ struct tevent_req *async_connect_send(
 	      errno == EISCONN ||
 #endif
 	      errno == EAGAIN || errno == EINTR)) {
-		state->sys_errno = errno;
-		goto post_errno;
+		tevent_req_error(req, errno);
+		return tevent_req_post(req, ev);
 	}
 
-	fde = tevent_add_fd(ev, state, fd, TEVENT_FD_READ | TEVENT_FD_WRITE,
-			   async_connect_connected, result);
-	if (fde == NULL) {
-		state->sys_errno = ENOMEM;
-		goto post_errno;
+	state->fde = tevent_add_fd(ev, state, fd,
+				   TEVENT_FD_READ | TEVENT_FD_WRITE,
+				   async_connect_connected, req);
+	if (state->fde == NULL) {
+		tevent_req_error(req, ENOMEM);
+		return tevent_req_post(req, ev);
 	}
-	return result;
+	return req;
+}
 
- post_errno:
-	tevent_req_error(result, state->sys_errno);
- done:
-	fcntl(fd, F_SETFL, state->old_sockflags);
-	return tevent_req_post(result, ev);
+static void async_connect_cleanup(struct tevent_req *req,
+				  enum tevent_req_state req_state)
+{
+	struct async_connect_state *state =
+		tevent_req_data(req, struct async_connect_state);
+
+	TALLOC_FREE(state->fde);
+	if (state->fd != -1) {
+		fcntl(state->fd, F_SETFL, state->old_sockflags);
+		state->fd = -1;
+	}
 }
 
 /**
@@ -359,8 +191,6 @@ static void async_connect_connected(struct tevent_context *ev,
 	}
 
 	if (ret == 0) {
-		state->sys_errno = 0;
-		TALLOC_FREE(fde);
 		tevent_req_done(req);
 		return;
 	}
@@ -368,36 +198,26 @@ static void async_connect_connected(struct tevent_context *ev,
 		/* Try again later, leave the fde around */
 		return;
 	}
-	state->sys_errno = errno;
-	TALLOC_FREE(fde);
 	tevent_req_error(req, errno);
 	return;
 }
 
 int async_connect_recv(struct tevent_req *req, int *perrno)
 {
-	struct async_connect_state *state =
-		tevent_req_data(req, struct async_connect_state);
-	int err;
+	int err = tevent_req_simple_recv_unix(req);
 
-	fcntl(state->fd, F_SETFL, state->old_sockflags);
-
-	if (tevent_req_is_unix_error(req, &err)) {
+	if (err != 0) {
 		*perrno = err;
 		return -1;
 	}
 
-	if (state->sys_errno == 0) {
-		return 0;
-	}
-
-	*perrno = state->sys_errno;
-	return -1;
+	return 0;
 }
 
 struct writev_state {
 	struct tevent_context *ev;
 	int fd;
+	struct tevent_fd *fde;
 	struct iovec *iov;
 	int count;
 	size_t total_size;
@@ -405,6 +225,8 @@ struct writev_state {
 	bool err_on_readability;
 };
 
+static void writev_cleanup(struct tevent_req *req,
+			   enum tevent_req_state req_state);
 static void writev_trigger(struct tevent_req *req, void *private_data);
 static void writev_handler(struct tevent_context *ev, struct tevent_fd *fde,
 			   uint16_t flags, void *private_data);
@@ -427,40 +249,46 @@ struct tevent_req *writev_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 	state->count = count;
 	state->iov = (struct iovec *)talloc_memdup(
 		state, iov, sizeof(struct iovec) * count);
-	if (state->iov == NULL) {
-		goto fail;
+	if (tevent_req_nomem(state->iov, req)) {
+		return tevent_req_post(req, ev);
 	}
 	state->flags = TEVENT_FD_WRITE|TEVENT_FD_READ;
 	state->err_on_readability = err_on_readability;
 
+	tevent_req_set_cleanup_fn(req, writev_cleanup);
+
 	if (queue == NULL) {
-		struct tevent_fd *fde;
-		fde = tevent_add_fd(state->ev, state, state->fd,
+		state->fde = tevent_add_fd(state->ev, state, state->fd,
 				    state->flags, writev_handler, req);
-		if (tevent_req_nomem(fde, req)) {
+		if (tevent_req_nomem(state->fde, req)) {
 			return tevent_req_post(req, ev);
 		}
 		return req;
 	}
 
 	if (!tevent_queue_add(queue, ev, req, writev_trigger, NULL)) {
-		goto fail;
+		tevent_req_nomem(NULL, req);
+		return tevent_req_post(req, ev);
 	}
 	return req;
- fail:
-	TALLOC_FREE(req);
-	return NULL;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list