b/async_req/async_sock.c libcli/smb/smbXcli_base.c debug
authorStefan Metzmacher <metze@samba.org>
Fri, 30 Sep 2016 04:10:34 +0000 (06:10 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 1 Jun 2018 12:35:10 +0000 (14:35 +0200)
lib/async_req/async_sock.c
libcli/smb/smbXcli_base.c

index 0a8a333f4f34152dedb6f3d423be3f4c3135144b..08b94211e4ce69ce9a255aee2b3971632fb9bfb6 100644 (file)
 #include <tevent.h>
 #include "lib/async_req/async_sock.h"
 #include "lib/util/iov_buf.h"
+#include "lib/util/debug.h"
 
 /* Note: lib/util/ is currently GPL */
 #include "lib/util/tevent_unix.h"
 #include "lib/util/samba_util.h"
 
+#undef DEBUG
+#define DEBUG( _level, body ) do {\
+       int level = 5; \
+  (void)( ((level) <= MAX_DEBUG_LEVEL) && \
+         unlikely(DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))           \
+       && (dbghdrclass( level, DBGC_CLASS, __location__, __FUNCTION__ )) \
+       && (dbgtext body) ); \
+} while(0)
 struct async_connect_state {
        int fd;
        struct tevent_fd *fde;
@@ -387,19 +396,25 @@ static void writev_handler(struct tevent_context *ev, struct tevent_fd *fde,
                }
        }
 
+DEBUG(0,("%s:%s: before writev... ev[%p]\n", __location__, __func__, state->ev));
        written = writev(state->fd, state->iov, state->count);
        if ((written == -1) && (errno == EINTR)) {
+DEBUG(0,("%s:%s: errno=%d - %s\n", __location__, __func__, errno, strerror(errno)));
                /* retry */
                return;
        }
        if (written == -1) {
+DEBUG(0,("%s:%s: errno=%d - %s\n", __location__, __func__, errno, strerror(errno)));
                tevent_req_error(req, errno);
                return;
        }
        if (written == 0) {
+               errno = EPIPE;
+DEBUG(0,("%s:%s: errno=%d - %s\n", __location__, __func__, errno, strerror(errno)));
                tevent_req_error(req, EPIPE);
                return;
        }
+DEBUG(0,("%s:%s: written %zd\n", __location__, __func__, written));
        state->total_size += written;
 
        ok = iov_advance(&state->iov, &state->count, written);
@@ -409,9 +424,11 @@ static void writev_handler(struct tevent_context *ev, struct tevent_fd *fde,
        }
 
        if (state->count == 0) {
+DEBUG(0,("%s:%s: done total %zu\n", __location__, __func__, state->total_size));
                tevent_req_done(req);
                return;
        }
+DEBUG(0,("%s:%s: more total %zu\n", __location__, __func__, state->total_size));
 }
 
 ssize_t writev_recv(struct tevent_req *req, int *perrno)
index 38f7af296ad6e951d08457b87d2b27f31a446e1c..fe08e515dfb3bd0f0e70b334f6187e86340be9bd 100644 (file)
 #include "lib/crypto/aes_ccm_128.h"
 #include "lib/crypto/aes_gcm_128.h"
 
+#undef DEBUG
+#define DEBUG( _level, body ) do {\
+       int level = 5; \
+  (void)( ((level) <= MAX_DEBUG_LEVEL) && \
+         unlikely(DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))           \
+       && (dbghdrclass( level, DBGC_CLASS, __location__, __FUNCTION__ )) \
+       && (dbgtext body) ); \
+} while(0)
 struct smbXcli_conn;
 struct smbXcli_req;
 struct smbXcli_session;
@@ -1195,6 +1203,7 @@ static bool smbXcli_conn_receive_next(struct smbXcli_conn *conn)
         * We're the first ones, add the read_smb request that waits for the
         * answer from the server
         */
+DEBUG(0,("%s:%s: state[%p] \n", __location__, __func__, state));
        conn->read_smb_req = read_smb_send(conn->pending,
                                           state->ev,
                                           conn->sock_fd);
@@ -1903,6 +1912,7 @@ static void smbXcli_conn_received(struct tevent_req *subreq)
 
        received = read_smb_recv(subreq, frame, &inbuf, &err);
        TALLOC_FREE(subreq);
+DEBUG(0,("%s:%s: received[%zu]\n", __location__, __func__, received));
        if (received == -1) {
                status = map_nt_error_from_unix_common(err);
                smbXcli_conn_disconnect(conn, status);
@@ -3421,6 +3431,7 @@ skip_credits:
                }
        }
 
+DEBUG(0,("%s:%s: state[%p] nbt_len[%u]\n", __location__, __func__, state, (unsigned)nbt_len));
        subreq = writev_send(state, state->ev, state->conn->outgoing,
                             state->conn->sock_fd, false, iov, num_iov);
        if (subreq == NULL) {
@@ -3492,6 +3503,7 @@ static void smb2cli_req_writev_done(struct tevent_req *subreq)
 
        state->write_req = NULL;
 
+DEBUG(0,("%s:%s: state[%p]\n", __location__, __func__, state));
        nwritten = writev_recv(subreq, &err);
        TALLOC_FREE(subreq);
        if (nwritten == -1) {