From 1e3822115c3b466632044fe64c908b6f2de5803a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 19 Jul 2011 12:56:51 +0200 Subject: s3:libsmb: move cli->pid to cli->smb1.pid and hide it behind cli_[g|s]etpid() metze --- source3/libsmb/clientgen.c | 15 ++++++++++----- source3/libsmb/clifile.c | 10 +++++----- source3/libsmb/proto.h | 1 + 3 files changed, 16 insertions(+), 10 deletions(-) (limited to 'source3/libsmb') diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index aac38df360..67e8e06d1a 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -68,7 +68,7 @@ void cli_setup_packet_buf(struct cli_state *cli, char *buf) uint16 flags2; cli->rap_error = 0; SIVAL(buf,smb_rcls,0); - SSVAL(buf,smb_pid,cli->pid); + SSVAL(buf,smb_pid,cli->smb1.pid); memset(buf+smb_pidhigh, 0, 12); SSVAL(buf,smb_uid,cli->vuid); SSVAL(buf,smb_mid,cli->smb1.mid); @@ -185,7 +185,6 @@ struct cli_state *cli_initialise_ex(int signing_state) cli->fd = -1; cli->raw_status = NT_STATUS_INTERNAL_ERROR; cli->cnum = -1; - cli->pid = (uint16)sys_getpid(); cli->vuid = UID_FIELD_INVALID; cli->protocol = PROTOCOL_NT1; cli->timeout = 20000; /* Timeout is in milliseconds. */ @@ -240,7 +239,8 @@ struct cli_state *cli_initialise_ex(int signing_state) cli->initialised = 1; cli->smb1.mid = 1; - cli->smb1.vc_num = cli->pid; + cli->smb1.pid = (uint16_t)sys_getpid(); + cli->smb1.vc_num = cli->smb1.pid; return cli; @@ -354,11 +354,16 @@ uint16_t cli_state_get_vc_num(struct cli_state *cli) uint16 cli_setpid(struct cli_state *cli, uint16 pid) { - uint16 ret = cli->pid; - cli->pid = pid; + uint16_t ret = cli->smb1.pid; + cli->smb1.pid = pid; return ret; } +uint16_t cli_getpid(struct cli_state *cli) +{ + return cli->smb1.pid; +} + /**************************************************************************** Set the case sensitivity flag on the packets. Returns old state. ****************************************************************************/ diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 8cf60ded81..6503e234e5 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -2556,7 +2556,7 @@ NTSTATUS cli_locktype(struct cli_state *cli, uint16_t fnum, SSVAL(vwv + 6, 0, 0); SSVAL(vwv + 7, 0, 1); - SSVAL(bytes, 0, cli->pid); + SSVAL(bytes, 0, cli_getpid(cli)); SIVAL(bytes, 2, offset); SIVAL(bytes, 6, len); @@ -2626,7 +2626,7 @@ struct tevent_req *cli_unlock_send(TALLOC_CTX *mem_ctx, SSVAL(state->vwv+6, 0, 1); SSVAL(state->vwv+7, 0, 0); - SSVAL(state->data, 0, cli->pid); + SSVAL(state->data, 0, cli_getpid(cli)); SIVAL(state->data, 2, offset); SIVAL(state->data, 6, len); @@ -2732,7 +2732,7 @@ NTSTATUS cli_lock64(struct cli_state *cli, uint16_t fnum, SSVAL(vwv + 6, 0, 0); SSVAL(vwv + 7, 0, 1); - SIVAL(bytes, 0, cli->pid); + SIVAL(bytes, 0, cli_getpid(cli)); SOFF_T_R(bytes, 4, offset); SOFF_T_R(bytes, 12, len); @@ -2786,7 +2786,7 @@ struct tevent_req *cli_unlock64_send(TALLOC_CTX *mem_ctx, SSVAL(state->vwv+6, 0, 1); SSVAL(state->vwv+7, 0, 0); - SIVAL(state->data, 0, cli->pid); + SIVAL(state->data, 0, cli_getpid(cli)); SOFF_T_R(state->data, 4, offset); SOFF_T_R(state->data, 12, len); @@ -2932,7 +2932,7 @@ static struct tevent_req *cli_posix_lock_internal_send(TALLOC_CTX *mem_ctx, POSIX_LOCK_FLAG_NOWAIT); } - SIVAL(&state->data, POSIX_LOCK_PID_OFFSET, cli->pid); + SIVAL(&state->data, POSIX_LOCK_PID_OFFSET, cli_getpid(cli)); SOFF_T(&state->data, POSIX_LOCK_START_OFFSET, offset); SOFF_T(&state->data, POSIX_LOCK_LEN_OFFSET, len); diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h index 7ba2aaccad..9775bd775d 100644 --- a/source3/libsmb/proto.h +++ b/source3/libsmb/proto.h @@ -166,6 +166,7 @@ void cli_shutdown(struct cli_state *cli); void cli_sockopt(struct cli_state *cli, const char *options); uint16_t cli_state_get_vc_num(struct cli_state *cli); uint16 cli_setpid(struct cli_state *cli, uint16 pid); +uint16_t cli_getpid(struct cli_state *cli); bool cli_set_case_sensitive(struct cli_state *cli, bool case_sensitive); struct tevent_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev, struct cli_state *cli, uint16_t num_echos, -- cgit