1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

lib: Remove server_id_str()

Call server_id_str_buf instead

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Apr 28 20:48:01 CEST 2015 on sn-devel-104
This commit is contained in:
Volker Lendecke 2015-04-28 11:30:58 +00:00 committed by Jeremy Allison
parent b2c34d45c0
commit 06f4ba3217
17 changed files with 87 additions and 79 deletions

View File

@ -876,7 +876,6 @@ char *server_id_str_buf(struct server_id id, struct server_id_buf *dst);
bool server_id_same_process(const struct server_id *p1,
const struct server_id *p2);
bool server_id_equal(const struct server_id *p1, const struct server_id *p2);
char *server_id_str(TALLOC_CTX *mem_ctx, const struct server_id *id);
struct server_id server_id_from_string(uint32_t local_vnn,
const char *pid_string);

View File

@ -65,23 +65,6 @@ char *server_id_str_buf(struct server_id id, struct server_id_buf *dst)
return dst->buf;
}
char *server_id_str(TALLOC_CTX *mem_ctx, const struct server_id *id)
{
struct server_id_buf tmp;
char *result;
result = talloc_strdup(mem_ctx, server_id_str_buf(*id, &tmp));
if (result == NULL) {
return NULL;
}
/*
* beautify the talloc_report output
*/
talloc_set_name_const(result, result);
return result;
}
struct server_id server_id_from_string(uint32_t local_vnn,
const char *pid_string)
{
@ -93,7 +76,7 @@ struct server_id server_id_from_string(uint32_t local_vnn,
/*
* We accept various forms with 1, 2 or 3 component forms
* because the server_id_str() can print different forms, and
* because the server_id_str_buf() can print different forms, and
* we want backwards compatibility for scripts that may call
* smbclient.
*/

View File

@ -58,11 +58,13 @@ struct byte_range_lock {
static void print_lock_struct(unsigned int i, const struct lock_struct *pls)
{
struct server_id_buf tmp;
DEBUG(10,("[%u]: smblctx = %llu, tid = %u, pid = %s, ",
i,
(unsigned long long)pls->context.smblctx,
(unsigned int)pls->context.tid,
server_id_str(talloc_tos(), &pls->context.pid) ));
server_id_str_buf(pls->context.pid, &tmp) ));
DEBUG(10, ("start = %ju, size = %ju, fnum = %ju, %s %s\n",
(uintmax_t)pls->start,
@ -2243,10 +2245,11 @@ bool brl_cleanup_disconnected(struct file_id fid, uint64_t open_persistent_id)
struct lock_context *ctx = &lock[n].context;
if (!server_id_is_disconnected(&ctx->pid)) {
struct server_id_buf tmp;
DEBUG(5, ("brl_cleanup_disconnected: byte range lock "
"%s used by server %s, do not cleanup\n",
file_id_string(frame, &fid),
server_id_str(frame, &ctx->pid)));
server_id_str_buf(ctx->pid, &tmp)));
goto done;
}

View File

@ -792,6 +792,7 @@ bool share_mode_cleanup_disconnected(struct file_id fid,
struct share_mode_entry *entry = &data->share_modes[n];
if (!server_id_is_disconnected(&entry->pid)) {
struct server_id_buf tmp;
DEBUG(5, ("share_mode_cleanup_disconnected: "
"file (file-id='%s', servicepath='%s', "
"base_name='%s%s%s') "
@ -803,7 +804,7 @@ bool share_mode_cleanup_disconnected(struct file_id fid,
? "" : "', stream_name='",
(data->stream_name == NULL)
? "" : data->stream_name,
server_id_str(frame, &entry->pid)));
server_id_str_buf(entry->pid, &tmp)));
goto done;
}
if (open_persistent_id != entry->share_file_id) {

View File

@ -776,6 +776,7 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
uint16_t break_from;
uint16_t break_to;
bool break_needed = true;
struct server_id_buf tmp;
if (data->data == NULL) {
DEBUG(0, ("Got NULL buffer\n"));
@ -792,7 +793,7 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
break_to = msg.op_type;
DEBUG(10, ("Got oplock break to %u message from pid %s: %s/%llu\n",
(unsigned)break_to, server_id_str(talloc_tos(), &src),
(unsigned)break_to, server_id_str_buf(src, &tmp),
file_id_string_tos(&msg.id),
(unsigned long long)msg.share_file_id));
@ -970,6 +971,7 @@ static void process_kernel_oplock_break(struct messaging_context *msg_ctx,
struct smbd_server_connection *sconn =
talloc_get_type_abort(private_data,
struct smbd_server_connection);
struct server_id_buf tmp;
if (data->data == NULL) {
DEBUG(0, ("Got NULL buffer\n"));
@ -986,7 +988,7 @@ static void process_kernel_oplock_break(struct messaging_context *msg_ctx,
file_id = (unsigned long)IVAL(data->data, 24);
DEBUG(10, ("Got kernel oplock break message from pid %s: %s/%u\n",
server_id_str(talloc_tos(), &src), file_id_string_tos(&id),
server_id_str_buf(src, &tmp), file_id_string_tos(&id),
(unsigned int)file_id));
fsp = initial_break_processing(sconn, id, file_id);

View File

@ -49,9 +49,11 @@ struct scavenger_message {
static int smbd_scavenger_main(struct smbd_scavenger_state *state)
{
struct server_id_buf tmp1, tmp2;
DEBUG(10, ("scavenger: %s started, parent: %s\n",
server_id_str(talloc_tos(), state->scavenger_id),
server_id_str(talloc_tos(), &state->parent_id)));
server_id_str_buf(*state->scavenger_id, &tmp1),
server_id_str_buf(state->parent_id, &tmp2)));
while (true) {
TALLOC_CTX *frame = talloc_stackframe();
@ -66,7 +68,7 @@ static int smbd_scavenger_main(struct smbd_scavenger_state *state)
}
DEBUG(10, ("scavenger: %s event loop iteration\n",
server_id_str(talloc_tos(), state->scavenger_id)));
server_id_str_buf(*state->scavenger_id, &tmp1)));
TALLOC_FREE(frame);
}
@ -78,9 +80,10 @@ static void smbd_scavenger_done(struct tevent_context *event_ctx, struct tevent_
{
struct smbd_scavenger_state *state = talloc_get_type_abort(
private_data, struct smbd_scavenger_state);
struct server_id_buf tmp;
DEBUG(2, ("scavenger: %s died\n",
server_id_str(talloc_tos(), state->scavenger_id)));
server_id_str_buf(*state->scavenger_id, &tmp)));
TALLOC_FREE(state->scavenger_id);
}
@ -91,10 +94,11 @@ static void smbd_scavenger_parent_dead(struct tevent_context *event_ctx,
{
struct smbd_scavenger_state *state = talloc_get_type_abort(
private_data, struct smbd_scavenger_state);
struct server_id_buf tmp1, tmp2;
DEBUG(2, ("scavenger: %s parent %s died\n",
server_id_str(talloc_tos(), state->scavenger_id),
server_id_str(talloc_tos(), &state->parent_id)));
server_id_str_buf(*state->scavenger_id, &tmp1),
server_id_str_buf(state->parent_id, &tmp2)));
exit_server("smbd_scavenger_parent_dead");
}
@ -143,6 +147,7 @@ static bool scavenger_say_hello(int fd, struct server_id self)
const uint8_t *msg = (const uint8_t *)&self;
size_t remaining = sizeof(self);
size_t ofs = 0;
struct server_id_buf tmp;
while (remaining > 0) {
ssize_t ret;
@ -157,7 +162,7 @@ static bool scavenger_say_hello(int fd, struct server_id self)
}
DEBUG(4, ("scavenger_say_hello: self[%s]\n",
server_id_str(talloc_tos(), &self)));
server_id_str_buf(self, &tmp)));
return true;
}
@ -166,6 +171,7 @@ static bool scavenger_wait_hello(int fd, struct server_id *child)
uint8_t *msg = (uint8_t *)child;
size_t remaining = sizeof(*child);
size_t ofs = 0;
struct server_id_buf tmp;
while (remaining > 0) {
ssize_t ret;
@ -180,7 +186,7 @@ static bool scavenger_wait_hello(int fd, struct server_id *child)
}
DEBUG(4, ("scavenger_say_hello: child[%s]\n",
server_id_str(talloc_tos(), child)));
server_id_str_buf(*child, &tmp)));
return true;
}
@ -196,16 +202,18 @@ static bool smbd_scavenger_start(struct smbd_scavenger_state *state)
SMB_ASSERT(server_id_equal(&state->parent_id, &self));
if (smbd_scavenger_running(state)) {
struct server_id_buf tmp;
DEBUG(10, ("scavenger %s already running\n",
server_id_str(talloc_tos(),
state->scavenger_id)));
server_id_str_buf(*state->scavenger_id,
&tmp)));
return true;
}
if (state->scavenger_id != NULL) {
struct server_id_buf tmp;
DEBUG(10, ("scavenger zombie %s, cleaning up\n",
server_id_str(talloc_tos(),
state->scavenger_id)));
server_id_str_buf(*state->scavenger_id,
&tmp)));
TALLOC_FREE(state->scavenger_id);
}
@ -328,10 +336,11 @@ static void smbd_scavenger_msg(struct messaging_context *msg_ctx,
TALLOC_CTX *frame = talloc_stackframe();
struct server_id self = messaging_server_id(msg_ctx);
struct scavenger_message *msg = NULL;
struct server_id_buf tmp1, tmp2;
DEBUG(10, ("smbd_scavenger_msg: %s got message from %s\n",
server_id_str(talloc_tos(), &self),
server_id_str(talloc_tos(), &src)));
server_id_str_buf(self, &tmp1),
server_id_str_buf(src, &tmp2)));
if (server_id_equal(&state->parent_id, &self)) {
NTSTATUS status;
@ -416,6 +425,7 @@ void scavenger_schedule_disconnected(struct files_struct *fsp)
uint64_t timeout_usec;
struct scavenger_message msg;
DATA_BLOB msg_blob;
struct server_id_buf tmp;
if (fsp->op == NULL) {
return;
@ -433,7 +443,7 @@ void scavenger_schedule_disconnected(struct files_struct *fsp)
DEBUG(10, ("smbd: %s mark file %s as disconnected at %s with timeout "
"at %s in %fs\n",
server_id_str(talloc_tos(), &self),
server_id_str_buf(self, &tmp),
file_id_string_tos(&fsp->file_id),
timeval_string(talloc_tos(), &disconnect_time, true),
timeval_string(talloc_tos(), &until, true),
@ -451,11 +461,12 @@ void scavenger_schedule_disconnected(struct files_struct *fsp)
MSG_SMB_SCAVENGER,
&msg_blob);
if (!NT_STATUS_IS_OK(status)) {
struct server_id_buf tmp1, tmp2;
DEBUG(2, ("Failed to send message to parent smbd %s "
"from %s: %s\n",
server_id_str(talloc_tos(),
&smbd_scavenger_state->parent_id),
server_id_str(talloc_tos(), &self),
server_id_str_buf(smbd_scavenger_state->parent_id,
&tmp1),
server_id_str_buf(self, &tmp2),
nt_errstr(status)));
}
}

View File

@ -511,9 +511,10 @@ static int shutdown_other_smbds(struct smbXsrv_session_global0 *session,
struct server_id self_pid = messaging_server_id(state->msg_ctx);
struct server_id pid = session->channels[0].server_id;
const char *addr = session->channels[0].remote_address;
struct server_id_buf tmp;
DEBUG(10, ("shutdown_other_smbds: %s, %s\n",
server_id_str(talloc_tos(), &pid), addr));
server_id_str_buf(pid, &tmp), addr));
if (!process_exists(pid)) {
DEBUG(10, ("process does not exist\n"));

View File

@ -630,10 +630,11 @@ static void smbXsrv_open_global_verify_record(struct db_record *db_rec,
exists = serverid_exists(&global->server_id);
}
if (!exists) {
struct server_id_buf idbuf;
DEBUG(2,("smbXsrv_open_global_verify_record: "
"key '%s' server_id %s does not exist.\n",
hex_encode_talloc(frame, key.dptr, key.dsize),
server_id_str(frame, &global->server_id)));
server_id_str_buf(global->server_id, &idbuf)));
if (CHECK_DEBUGLVL(2)) {
NDR_PRINT_DEBUG(smbXsrv_open_globalB, &global_blob);
}
@ -1453,9 +1454,11 @@ NTSTATUS smbXsrv_open_cleanup(uint64_t persistent_id)
op->durable_timeout_msec / 1000,
delete_open ? "" : " not"));
} else if (!serverid_exists(&op->server_id)) {
struct server_id_buf idbuf;
DEBUG(10, ("smbXsrv_open_cleanup[global: 0x%08x] "
"server[%s] does not exist\n",
global_id, server_id_str(frame, &op->server_id)));
global_id,
server_id_str_buf(op->server_id, &idbuf)));
delete_open = true;
}

View File

@ -782,10 +782,12 @@ static void smbXsrv_session_global_verify_record(struct db_record *db_rec,
exists = serverid_exists(&global->channels[0].server_id);
if (!exists) {
struct server_id_buf idbuf;
DEBUG(2,("smbXsrv_session_global_verify_record: "
"key '%s' server_id %s does not exist.\n",
hex_encode_talloc(frame, key.dptr, key.dsize),
server_id_str(frame, &global->channels[0].server_id)));
server_id_str_buf(global->channels[0].server_id,
&idbuf)));
if (DEBUGLVL(2)) {
NDR_PRINT_DEBUG(smbXsrv_session_globalB, &global_blob);
}

View File

@ -604,10 +604,11 @@ static void smbXsrv_tcon_global_verify_record(struct db_record *db_rec,
exists = serverid_exists(&global->server_id);
if (!exists) {
struct server_id_buf idbuf;
DEBUG(2,("smbXsrv_tcon_global_verify_record: "
"key '%s' server_id %s does not exist.\n",
hex_encode_talloc(frame, key.dptr, key.dsize),
server_id_str(frame, &global->server_id)));
server_id_str_buf(global->server_id, &idbuf)));
if (DEBUGLVL(2)) {
NDR_PRINT_DEBUG(smbXsrv_tcon_globalB, &global_blob);
}

View File

@ -353,9 +353,8 @@ static int dbwrap_tool_listwatchers_cb(const uint8_t *db_id, size_t db_id_len,
dump_data_file(key.dptr, key.dsize, false, stdout);
for (i=0; i<num_watchers; i++) {
char *str = server_id_str(talloc_tos(), &watchers[i]);
printf("%s\n", str);
TALLOC_FREE(str);
struct server_id_buf idbuf;
printf("%s\n", server_id_str_buf(watchers[i], &idbuf));
}
printf("\n");
return 0;

View File

@ -111,12 +111,9 @@ done:
static int net_g_lock_dump_fn(struct server_id pid, enum g_lock_type lock_type,
void *private_data)
{
char *pidstr;
pidstr = server_id_str(talloc_tos(), &pid);
d_printf("%s: %s\n", pidstr,
struct server_id_buf idbuf;
d_printf("%s: %s\n", server_id_str_buf(pid, &idbuf),
(lock_type & 1) ? "WRITE" : "READ");
TALLOC_FREE(pidstr);
return 0;
}

View File

@ -30,10 +30,10 @@
static int net_serverid_list_fn(const struct server_id *id,
uint32_t msg_flags, void *priv)
{
char *str = server_id_str(talloc_tos(), id);
d_printf("%s %llu 0x%x\n", str, (unsigned long long)id->unique_id,
struct server_id_buf idbuf;
d_printf("%s %llu 0x%x\n", server_id_str_buf(*id, &idbuf),
(unsigned long long)id->unique_id,
(unsigned int)msg_flags);
TALLOC_FREE(str);
return 0;
}
@ -55,10 +55,9 @@ static int net_serverid_wipe_fn(struct db_record *rec,
}
status = dbwrap_record_delete(rec);
if (!NT_STATUS_IS_OK(status)) {
char *str = server_id_str(talloc_tos(), id);
struct server_id_buf idbuf;
DEBUG(1, ("Could not delete serverid.tdb record %s: %s\n",
str, nt_errstr(status)));
TALLOC_FREE(str);
server_id_str_buf(*id, &idbuf), nt_errstr(status)));
}
return 0;
}
@ -125,34 +124,39 @@ static struct wipedbs_server_data *get_server_data(struct wipedbs_state *state,
ret = *(struct wipedbs_server_data**) val.dptr;
TALLOC_FREE(val.dptr);
} else if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
struct server_id_buf idbuf;
server_id_str_buf(*id, &idbuf);
ret = talloc_zero(state->id2server_data,
struct wipedbs_server_data);
if (ret == NULL) {
DEBUG(0, ("Failed to allocate server entry for %s\n",
server_id_str(talloc_tos(), id)));
idbuf.buf));
goto done;
}
ret->server_id = *id;
ret->server_id_str = server_id_str(ret, id);
ret->server_id_str = talloc_strdup(ret, idbuf.buf);
ret->exists = true;
val = make_tdb_data((const void*)&ret, sizeof(ret));
status = dbwrap_store(state->id2server_data,
key, val, TDB_INSERT);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Failed to store server entry for %s: %s\n",
server_id_str(talloc_tos(), id),
nt_errstr(status)));
idbuf.buf, nt_errstr(status)));
}
goto done;
} else {
struct server_id_buf idbuf;
DEBUG(0, ("Failed to fetch server entry for %s: %s\n",
server_id_str(talloc_tos(), id), nt_errstr(status)));
server_id_str_buf(*id, &idbuf), nt_errstr(status)));
goto done;
}
if (!server_id_equal(id, &ret->server_id)) {
struct server_id_buf idbuf1, idbuf2;
DEBUG(0, ("uniq id collision for %s and %s\n",
server_id_str(talloc_tos(), id),
server_id_str(talloc_tos(), &ret->server_id)));
server_id_str_buf(*id, &idbuf1),
server_id_str_buf(ret->server_id, &idbuf2)));
smb_panic("server_id->unique_id not unique!");
}
done:

View File

@ -340,12 +340,11 @@ static void print_notify_recs(const char *path,
for (i=0; i<num_entries; i++) {
struct notify_db_entry *e = &entries[i];
char *str;
struct server_id_buf idbuf;
str = server_id_str(talloc_tos(), &e->server);
printf("%s %x %x\n", str, (unsigned)e->filter,
printf("%s %x %x\n", server_id_str_buf(e->server, &idbuf),
(unsigned)e->filter,
(unsigned)e->subdir_filter);
TALLOC_FREE(str);
}
printf("\n");
}

View File

@ -101,9 +101,11 @@ static int ridalloc_poke_rid_manager(struct ldb_module *module)
/* Only error out if an error happened, not on STATUS_MORE_ENTRIES, ie a delayed message */
if (NT_STATUS_IS_ERR(status)) {
struct server_id_buf idbuf;
ldb_asprintf_errstring(ldb_module_get_ctx(module),
"Failed to send MSG_DREPL_ALLOCATE_RID to dreplsrv at %s: %s",
server_id_str(tmp_ctx, servers), nt_errstr(status));
server_id_str_buf(*servers, &idbuf),
nt_errstr(status));
talloc_free(tmp_ctx);
return LDB_ERR_UNWILLING_TO_PERFORM;
}

View File

@ -471,7 +471,7 @@ static void switch_message(int type, struct smbsrv_request *req)
int flags;
struct smbsrv_connection *smb_conn = req->smb_conn;
NTSTATUS status;
char *task_id;
struct server_id_buf idbuf;
type &= 0xff;
@ -495,10 +495,10 @@ static void switch_message(int type, struct smbsrv_request *req)
req->session = smbsrv_session_find(req->smb_conn, SVAL(req->in.hdr,HDR_UID), req->request_time);
}
task_id = server_id_str(NULL, &req->smb_conn->connection->server_id);
DEBUG(5,("switch message %s (task_id %s)\n",
smb_fn_name(type), task_id));
talloc_free(task_id);
DEBUG(5, ("switch message %s (task_id %s)\n",
smb_fn_name(type),
server_id_str_buf(req->smb_conn->connection->server_id,
&idbuf)));
/* this must be called before we do any reply */
if (flags & SIGNING_NO_REPLY) {

View File

@ -215,6 +215,7 @@ static void stream_new_connection(struct tevent_context *ev,
{
TALLOC_CTX *tmp_ctx;
const char *title;
struct server_id_buf idbuf;
tmp_ctx = talloc_new(srv_conn);
@ -222,7 +223,7 @@ static void stream_new_connection(struct tevent_context *ev,
stream_socket->ops->name,
tsocket_address_string(srv_conn->remote_address, tmp_ctx),
tsocket_address_string(srv_conn->local_address, tmp_ctx),
server_id_str(tmp_ctx, &server_id));
server_id_str_buf(server_id, &idbuf));
if (title) {
stream_connection_set_title(srv_conn, title);
}