[SCM] Samba Shared Repository - branch master updated
Jelmer Vernooij
jelmer at samba.org
Sat Mar 24 14:56:03 MDT 2012
The branch, master has been updated
via c0288e0 lib/util: Remove obsolete sys_getpid() and sys_fork().
from 55bd279 lib/util: Allow calloc use in util.c, too.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit c0288e0612187ecbfc4a81d071fd504ea8737b7a
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sat Mar 24 20:17:08 2012 +0100
lib/util: Remove obsolete sys_getpid() and sys_fork().
The performance of these is minimal (these days) and they can return
invalid results when used as part of applications that do not use
sys_fork().
Autobuild-User: Jelmer Vernooij <jelmer at samba.org>
Autobuild-Date: Sat Mar 24 21:55:41 CET 2012 on sn-devel-104
-----------------------------------------------------------------------
Summary of changes:
lib/util/become_daemon.c | 2 +-
lib/util/fault.c | 2 +-
lib/util/samba_util.h | 10 --------
lib/util/system.c | 31 --------------------------
source3/auth/pass_check.c | 4 +-
source3/client/client.c | 4 +-
source3/include/rpc_misc.h | 4 +-
source3/lib/ctdbd_conn.c | 4 +-
source3/lib/pidfile.c | 2 +-
source3/lib/server_prefork.c | 4 +-
source3/lib/smbldap.c | 4 +-
source3/lib/smbrun.c | 4 +-
source3/lib/substitute.c | 2 +-
source3/lib/system.c | 2 +-
source3/lib/tdb_validate.c | 2 +-
source3/lib/util.c | 8 +++---
source3/libsmb/clientgen.c | 2 +-
source3/libsmb/libsmb_context.c | 2 +-
source3/modules/vfs_aio_fork.c | 2 +-
source3/modules/vfs_notify_fam.c | 2 +-
source3/modules/vfs_preopen.c | 2 +-
source3/nmbd/asyncdns.c | 2 +-
source3/nmbd/nmbd.c | 2 +-
source3/nmbd/nmbd_packets.c | 2 +-
source3/nmbd/nmbd_synclists.c | 2 +-
source3/nmbd/nmbd_winsserver.c | 4 +-
source3/passdb/pdb_smbpasswd.c | 2 +-
source3/passdb/secrets.c | 2 +-
source3/printing/print_cups.c | 2 +-
source3/printing/printing.c | 20 ++++++++--------
source3/printing/printing_db.c | 2 +-
source3/printing/queue_process.c | 2 +-
source3/printing/spoolssd.c | 2 +-
source3/rpc_server/epmd.c | 2 +-
source3/rpc_server/lsasd.c | 2 +-
source3/rpc_server/rpc_handles.c | 2 +-
source3/rpc_server/samr/srv_samr_chgpasswd.c | 2 +-
source3/rpc_server/svcctl/srv_svcctl_nt.c | 2 +-
source3/smbd/files.c | 2 +-
source3/smbd/negprot.c | 28 +++++++++++-----------
source3/smbd/oplock_irix.c | 2 +-
source3/smbd/process.c | 22 +++++++++---------
source3/smbd/server.c | 6 ++--
source3/smbd/service.c | 2 +-
source3/smbd/session.c | 2 +-
source3/smbd/utmp.c | 2 +-
source3/winbindd/winbindd.c | 2 +-
source3/winbindd/winbindd_cm.c | 4 +-
source3/winbindd/winbindd_dual.c | 6 ++--
49 files changed, 95 insertions(+), 136 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/util/become_daemon.c b/lib/util/become_daemon.c
index 4c1d29e..92a7586 100644
--- a/lib/util/become_daemon.c
+++ b/lib/util/become_daemon.c
@@ -75,7 +75,7 @@ _PUBLIC_ void close_low_fds(bool stdin_too, bool stdout_too, bool stderr_too)
_PUBLIC_ void become_daemon(bool do_fork, bool no_process_group, bool log_stdout)
{
if (do_fork) {
- if (sys_fork()) {
+ if (fork()) {
_exit(0);
}
}
diff --git a/lib/util/fault.c b/lib/util/fault.c
index b3527bb..d0b34e5 100644
--- a/lib/util/fault.c
+++ b/lib/util/fault.c
@@ -70,7 +70,7 @@ static void fault_report(int sig)
counter++;
DEBUGSEP(0);
- DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)sys_getpid(),SAMBA_VERSION_STRING));
+ DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)getpid(),SAMBA_VERSION_STRING));
DEBUG(0,("\nPlease read the Trouble-Shooting section of the Samba HOWTO\n"));
DEBUGSEP(0);
diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h
index f989231..6096722 100644
--- a/lib/util/samba_util.h
+++ b/lib/util/samba_util.h
@@ -113,16 +113,6 @@ void CatchChild(void);
**/
void CatchChildLeaveStatus(void);
-/**
- * Wrapper for fork used to invalid pid cache.
- **/
-_PUBLIC_ pid_t sys_fork(void);
-
-/**
- * Wrapper for getpid. Ensures we only do a system call *once*.
- **/
-_PUBLIC_ pid_t sys_getpid(void);
-
struct sockaddr;
_PUBLIC_ int sys_getnameinfo(const struct sockaddr *psa,
diff --git a/lib/util/system.c b/lib/util/system.c
index f34fabd..558aa5b 100644
--- a/lib/util/system.c
+++ b/lib/util/system.c
@@ -40,37 +40,6 @@
*/
-/**************************************************************************
- Wrapper for fork. Ensures we clear our pid cache.
-****************************************************************************/
-
-static pid_t mypid = (pid_t)-1;
-
-_PUBLIC_ pid_t sys_fork(void)
-{
- pid_t forkret = fork();
-
- if (forkret == (pid_t)0) {
- /* Child - reset mypid so sys_getpid does a system call. */
- mypid = (pid_t) -1;
- }
-
- return forkret;
-}
-
-/**************************************************************************
- Wrapper for getpid. Ensures we only do a system call *once*.
-****************************************************************************/
-
-_PUBLIC_ pid_t sys_getpid(void)
-{
- if (mypid == (pid_t)-1)
- mypid = getpid();
-
- return mypid;
-}
-
-
_PUBLIC_ int sys_getnameinfo(const struct sockaddr *psa,
int salen,
char *host,
diff --git a/source3/auth/pass_check.c b/source3/auth/pass_check.c
index 74d6f1f..ca99261 100644
--- a/source3/auth/pass_check.c
+++ b/source3/auth/pass_check.c
@@ -378,7 +378,7 @@ static bool dfs_auth(char *user, char *password)
}
DEBUG(0, ("DCE login succeeded for principal %s on pid %d\n",
- user, sys_getpid()));
+ user, getpid()));
DEBUG(3, ("DCE principal: %s\n"
" uid: %d\n"
@@ -431,7 +431,7 @@ void dfs_unlogin(void)
dce_error_inq_text(err, dce_errstr, &err2);
DEBUG(0,
("DCE purge login context failed for server instance %d: %s\n",
- sys_getpid(), dce_errstr));
+ getpid(), dce_errstr));
}
}
#endif
diff --git a/source3/client/client.c b/source3/client/client.c
index 87ec3a9..0d60103 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -2292,12 +2292,12 @@ static int cmd_print(void)
rname = talloc_asprintf(ctx,
"%s-%d",
p+1,
- (int)sys_getpid());
+ (int)getpid());
}
if (strequal(lname,"-")) {
rname = talloc_asprintf(ctx,
"stdin-%d",
- (int)sys_getpid());
+ (int)getpid());
}
if (!rname) {
return 1;
diff --git a/source3/include/rpc_misc.h b/source3/include/rpc_misc.h
index adc8016..a33406a 100644
--- a/source3/include/rpc_misc.h
+++ b/source3/include/rpc_misc.h
@@ -28,8 +28,8 @@
**********************************************************************/
#define OUR_HANDLE(hnd) (((hnd)==NULL) ? "NULL" :\
- ( IVAL((hnd)->uuid.node,2) == (uint32)sys_getpid() ? "OURS" : \
+ ( IVAL((hnd)->uuid.node,2) == (uint32)getpid() ? "OURS" : \
"OTHER")), ((unsigned int)IVAL((hnd)->uuid.node,2)),\
- ((unsigned int)sys_getpid() )
+ ((unsigned int)getpid() )
#endif /* _RPC_MISC_H */
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 36e9e50..ba51137 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -578,7 +578,7 @@ NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
return status;
}
- status = register_with_ctdbd(conn, (uint64_t)sys_getpid());
+ status = register_with_ctdbd(conn, (uint64_t)getpid());
if (!NT_STATUS_IS_OK(status)) {
goto fail;
}
@@ -665,7 +665,7 @@ static NTSTATUS ctdb_handle_message(uint8_t *buf, size_t length,
}
/* only messages to our pid or the broadcast are valid here */
- if (msg->srvid != sys_getpid() && msg->srvid != MSG_SRVID_SAMBA) {
+ if (msg->srvid != getpid() && msg->srvid != MSG_SRVID_SAMBA) {
DEBUG(0,("Got unexpected message with srvid=%llu\n",
(unsigned long long)msg->srvid));
TALLOC_FREE(buf);
diff --git a/source3/lib/pidfile.c b/source3/lib/pidfile.c
index 06fca91..469ddbd 100644
--- a/source3/lib/pidfile.c
+++ b/source3/lib/pidfile.c
@@ -162,7 +162,7 @@ void pidfile_create(const char *program_name)
}
memset(buf, 0, sizeof(buf));
- slprintf(buf, sizeof(buf) - 1, "%u\n", (unsigned int) sys_getpid());
+ slprintf(buf, sizeof(buf) - 1, "%u\n", (unsigned int)getpid());
if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) {
DEBUG(0,("ERROR: can't write to file %s: %s\n",
pidFile_name, strerror(errno)));
diff --git a/source3/lib/server_prefork.c b/source3/lib/server_prefork.c
index f9df914..3d35e1c 100644
--- a/source3/lib/server_prefork.c
+++ b/source3/lib/server_prefork.c
@@ -106,7 +106,7 @@ bool prefork_create_pool(TALLOC_CTX *mem_ctx,
pfp->pool[i].allowed_clients = 1;
pfp->pool[i].started = now;
- pid = sys_fork();
+ pid = fork();
switch (pid) {
case -1:
DEBUG(1, ("Failed to prefork child n. %d !\n", i));
@@ -194,7 +194,7 @@ int prefork_add_children(struct tevent_context *ev_ctx,
pfp->pool[i].allowed_clients = 1;
pfp->pool[i].started = now;
- pid = sys_fork();
+ pid = fork();
switch (pid) {
case -1:
DEBUG(1, ("Failed to prefork child n. %d !\n", j));
diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c
index 51bcabd..c01d3fd 100644
--- a/source3/lib/smbldap.c
+++ b/source3/lib/smbldap.c
@@ -1070,7 +1070,7 @@ static int smbldap_open(struct smbldap_state *ldap_state)
ldap_state->last_ping = time_mono(NULL);
- ldap_state->pid = sys_getpid();
+ ldap_state->pid = getpid();
TALLOC_FREE(ldap_state->idle_event);
@@ -1157,7 +1157,7 @@ static void setup_ldap_local_alarm(struct smbldap_state *ldap_state, time_t abso
alarm(absolute_endtime - now);
}
- if (ldap_state->pid != sys_getpid()) {
+ if (ldap_state->pid != getpid()) {
smbldap_close(ldap_state);
}
}
diff --git a/source3/lib/smbrun.c b/source3/lib/smbrun.c
index 75713d2..b38dee1 100644
--- a/source3/lib/smbrun.c
+++ b/source3/lib/smbrun.c
@@ -92,7 +92,7 @@ static int smbrun_internal(const char *cmd, int *outfd, bool sanitize)
CatchChildLeaveStatus();
- if ((pid=sys_fork()) < 0) {
+ if ((pid=fork()) < 0) {
DEBUG(0,("smbrun: fork failed with error %s\n", strerror(errno) ));
CatchChild();
if (outfd) {
@@ -255,7 +255,7 @@ int smbrunsecret(const char *cmd, const char *secret)
CatchChildLeaveStatus();
- if ((pid=sys_fork()) < 0) {
+ if ((pid=fork()) < 0) {
DEBUG(0, ("smbrunsecret: fork failed with error %s\n", strerror(errno)));
CatchChild();
return errno;
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c
index 08cc03e..4458286 100644
--- a/source3/lib/substitute.c
+++ b/source3/lib/substitute.c
@@ -549,7 +549,7 @@ char *talloc_sub_basic(TALLOC_CTX *mem_ctx,
get_remote_arch_str());
break;
case 'd' :
- slprintf(pidstr,sizeof(pidstr)-1, "%d",(int)sys_getpid());
+ slprintf(pidstr,sizeof(pidstr)-1, "%d",(int)getpid());
a_string = realloc_string_sub(a_string, "%d", pidstr);
break;
case 'h' :
diff --git a/source3/lib/system.c b/source3/lib/system.c
index f655853..92e244f 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -1404,7 +1404,7 @@ int sys_popen(const char *command)
if(!(argl = extract_args(NULL, command)))
goto err_exit;
- entry->child_pid = sys_fork();
+ entry->child_pid = fork();
if (entry->child_pid == -1) {
goto err_exit;
diff --git a/source3/lib/tdb_validate.c b/source3/lib/tdb_validate.c
index 385f4d0..e4f7520 100644
--- a/source3/lib/tdb_validate.c
+++ b/source3/lib/tdb_validate.c
@@ -118,7 +118,7 @@ int tdb_validate(struct tdb_context *tdb, tdb_validate_data_func validate_fn)
* just let the child panic. we catch the signal. */
DEBUG(10, ("tdb_validate: forking to let child do validation.\n"));
- child_pid = sys_fork();
+ child_pid = fork();
if (child_pid == 0) {
/* child code */
DEBUG(10, ("tdb_validate (validation child): created\n"));
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 9d3d787..7be056c 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -860,7 +860,7 @@ void smb_panic_s3(const char *why)
int result;
DEBUG(0,("PANIC (pid %llu): %s\n",
- (unsigned long long)sys_getpid(), why));
+ (unsigned long long)getpid(), why));
log_stack_trace();
#if defined(HAVE_PRCTL) && defined(PR_SET_PTRACER)
@@ -1985,7 +1985,7 @@ static uint32 my_vnn = NONCLUSTER_VNN;
void set_my_vnn(uint32 vnn)
{
- DEBUG(10, ("vnn pid %d = %u\n", (int)sys_getpid(), (unsigned int)vnn));
+ DEBUG(10, ("vnn pid %d = %u\n", (int)getpid(), (unsigned int)vnn));
my_vnn = vnn;
}
@@ -2013,7 +2013,7 @@ struct server_id pid_to_procid(pid_t pid)
struct server_id procid_self(void)
{
- return pid_to_procid(sys_getpid());
+ return pid_to_procid(getpid());
}
bool procid_equal(const struct server_id *p1, const struct server_id *p2)
@@ -2035,7 +2035,7 @@ bool cluster_id_equal(const struct server_id *id1,
bool procid_is_me(const struct server_id *pid)
{
- if (pid->pid != sys_getpid())
+ if (pid->pid != getpid())
return False;
if (pid->task_id != 0)
return False;
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 26fbd19..75948b8 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -271,7 +271,7 @@ struct cli_state *cli_state_create(TALLOC_CTX *mem_ctx,
goto error;
}
- cli->smb1.pid = (uint16_t)sys_getpid();
+ cli->smb1.pid = (uint16_t)getpid();
cli->smb1.vc_num = cli->smb1.pid;
cli->smb1.tid = UINT16_MAX;
cli->smb1.uid = UID_FIELD_INVALID;
diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c
index 6c78cb9..a8fd2dc 100644
--- a/source3/libsmb/libsmb_context.c
+++ b/source3/libsmb/libsmb_context.c
@@ -604,7 +604,7 @@ smbc_init_context(SMBCCTX *context)
* Hmmm, I want to get hostname as well, but I am too
* lazy for the moment
*/
- pid = sys_getpid();
+ pid = getpid();
netbios_name = (char *)SMB_MALLOC(17);
if (!netbios_name) {
errno = ENOMEM;
diff --git a/source3/modules/vfs_aio_fork.c b/source3/modules/vfs_aio_fork.c
index bcd7c6a..27f7116 100644
--- a/source3/modules/vfs_aio_fork.c
+++ b/source3/modules/vfs_aio_fork.c
@@ -500,7 +500,7 @@ static NTSTATUS create_aio_child(struct smbd_server_connection *sconn,
goto fail;
}
- result->pid = sys_fork();
+ result->pid = fork();
if (result->pid == -1) {
status = map_nt_error_from_unix(errno);
DEBUG(0, ("fork failed: %s\n", strerror(errno)));
diff --git a/source3/modules/vfs_notify_fam.c b/source3/modules/vfs_notify_fam.c
index 8a3487b..7ac6609 100644
--- a/source3/modules/vfs_notify_fam.c
+++ b/source3/modules/vfs_notify_fam.c
@@ -87,7 +87,7 @@ static NTSTATUS fam_open_connection(FAMConnection *fam_conn,
setenv("GAM_CLIENT_ID","SAMBA",0);
#endif
- if (asprintf(&name, "smbd (%lu)", (unsigned long)sys_getpid()) == -1) {
+ if (asprintf(&name, "smbd (%lu)", (unsigned long)getpid()) == -1) {
DEBUG(0, ("No memory\n"));
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/modules/vfs_preopen.c b/source3/modules/vfs_preopen.c
index 3d7f6c1..3540d34 100644
--- a/source3/modules/vfs_preopen.c
+++ b/source3/modules/vfs_preopen.c
@@ -224,7 +224,7 @@ static NTSTATUS preopen_init_helper(struct preopen_helper *h)
return status;
}
- h->pid = sys_fork();
+ h->pid = fork();
if (h->pid == -1) {
return map_nt_error_from_unix(errno);
diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c
index a42ad25..90340ef 100644
--- a/source3/nmbd/asyncdns.c
+++ b/source3/nmbd/asyncdns.c
@@ -147,7 +147,7 @@ void start_async_dns(struct messaging_context *msg)
return;
}
- child_pid = sys_fork();
+ child_pid = fork();
if (child_pid) {
fd_in = fd1[0];
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index eff1eca..bb264d2 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -830,7 +830,7 @@ static bool open_sockets(bool isdaemon, int port)
StartupTime = time(NULL);
- sys_srandom(time(NULL) ^ sys_getpid());
+ sys_srandom(time(NULL) ^ getpid());
if (!override_logfile) {
char *lfile = NULL;
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c
index f8bfe45..7a707a0 100644
--- a/source3/nmbd/nmbd_packets.c
+++ b/source3/nmbd/nmbd_packets.c
@@ -150,7 +150,7 @@ static uint16 name_trn_id=0;
static uint16 generate_name_trn_id(void)
{
if (!name_trn_id) {
- name_trn_id = ((unsigned)time(NULL)%(unsigned)0x7FFF) + ((unsigned)sys_getpid()%(unsigned)100);
+ name_trn_id = ((unsigned)time(NULL)%(unsigned)0x7FFF) + ((unsigned)getpid()%(unsigned)100);
}
name_trn_id = (name_trn_id+1) % (unsigned)0x7FFF;
return name_trn_id;
diff --git a/source3/nmbd/nmbd_synclists.c b/source3/nmbd/nmbd_synclists.c
index 1adccbd..20ece69 100644
--- a/source3/nmbd/nmbd_synclists.c
+++ b/source3/nmbd/nmbd_synclists.c
@@ -167,7 +167,7 @@ done:
/* the parent forks and returns, leaving the child to do the
actual sync and call END_PROFILE*/
CatchChild();
- if ((s->pid = sys_fork())) return;
+ if ((s->pid = fork())) return;
BlockSignals( False, SIGTERM );
diff --git a/source3/nmbd/nmbd_winsserver.c b/source3/nmbd/nmbd_winsserver.c
index 48c10e2..0a06ebe 100644
--- a/source3/nmbd/nmbd_winsserver.c
+++ b/source3/nmbd/nmbd_winsserver.c
@@ -2470,7 +2470,7 @@ void wins_write_database(time_t t, bool background)
/* We will do the writing in a child process to ensure that the parent doesn't block while this is done */
if (background) {
CatchChild();
- if (sys_fork()) {
+ if (fork()) {
return;
}
if (tdb_reopen(wins_tdb)) {
@@ -2487,7 +2487,7 @@ void wins_write_database(time_t t, bool background)
/* This is safe as the 0 length means "don't expand". */
all_string_sub(fname,"//", "/", 0);
- if (asprintf(&fnamenew, "%s.%u", fname, (unsigned int)sys_getpid()) < 0) {
+ if (asprintf(&fnamenew, "%s.%u", fname, (unsigned int)getpid()) < 0) {
goto err_exit;
}
diff --git a/source3/passdb/pdb_smbpasswd.c b/source3/passdb/pdb_smbpasswd.c
index 6dbb72a..4d5bed4 100644
--- a/source3/passdb/pdb_smbpasswd.c
+++ b/source3/passdb/pdb_smbpasswd.c
@@ -1095,7 +1095,7 @@ static bool del_smbfilepwd_entry(struct smbpasswd_privates *smbpasswd_state, con
pfile2 = talloc_asprintf(talloc_tos(),
"%s.%u",
- pfile, (unsigned)sys_getpid());
+ pfile, (unsigned)getpid());
if (!pfile2) {
return false;
}
diff --git a/source3/passdb/secrets.c b/source3/passdb/secrets.c
index 94e514d..33a266c 100644
--- a/source3/passdb/secrets.c
+++ b/source3/passdb/secrets.c
@@ -47,7 +47,7 @@ static struct db_context *db_ctx;
*/
static void get_rand_seed(void *userdata, int *new_seed)
{
- *new_seed = sys_getpid();
+ *new_seed = getpid();
if (db_ctx) {
dbwrap_trans_change_int32_atomic(db_ctx, "INFO/random_seed",
new_seed, 1);
diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c
index 95ddd57..79b146c 100644
--- a/source3/printing/print_cups.c
+++ b/source3/printing/print_cups.c
@@ -411,7 +411,7 @@ static bool cups_pcap_load_async(struct tevent_context *ev,
return false;
}
- pid = sys_fork();
+ pid = fork();
--
Samba Shared Repository
More information about the samba-cvs
mailing list