summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-05-02 02:23:41 +0000
committerJeremy Allison <jra@samba.org>2000-05-02 02:23:41 +0000
commit693ffb8466ada58ecc59fde754ba79fc6f51528d (patch)
tree639fae54b3d874aae78e5732aef20f52de5b60bf /source3/smbd
parent830a9e571eee5330097376e94af7dc0f2d5f2f02 (diff)
downloadsamba-693ffb8466ada58ecc59fde754ba79fc6f51528d.tar.gz
samba-693ffb8466ada58ecc59fde754ba79fc6f51528d.tar.bz2
samba-693ffb8466ada58ecc59fde754ba79fc6f51528d.zip
Added sys_fork() and sys_getpid() functions to stop the overhead
of doing a system call every time we want to just get our pid. Jeremy. (This used to be commit 148628b616b5c29ba6340d65fc3ddbcabba6e67a)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/chgpasswd.c2
-rw-r--r--source3/smbd/connection.c6
-rw-r--r--source3/smbd/fileio.c2
-rw-r--r--source3/smbd/files.c2
-rw-r--r--source3/smbd/negprot.c6
-rw-r--r--source3/smbd/open.c4
-rw-r--r--source3/smbd/oplock.c6
-rw-r--r--source3/smbd/password.c4
-rw-r--r--source3/smbd/process.c2
-rw-r--r--source3/smbd/server.c2
-rw-r--r--source3/smbd/service.c2
11 files changed, 19 insertions, 19 deletions
diff --git a/source3/smbd/chgpasswd.c b/source3/smbd/chgpasswd.c
index 484523bd27..708b52f4bc 100644
--- a/source3/smbd/chgpasswd.c
+++ b/source3/smbd/chgpasswd.c
@@ -330,7 +330,7 @@ static BOOL chat_with_program(char *passwordprogram, char *name,
CatchChildLeaveStatus();
- if ((pid = fork()) < 0)
+ if ((pid = sys_fork()) < 0)
{
DEBUG(3,
("Cannot fork() child for password change: %s\n",
diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c
index 9c859e4d89..aa49f8cf7c 100644
--- a/source3/smbd/connection.c
+++ b/source3/smbd/connection.c
@@ -45,7 +45,7 @@ BOOL yield_connection(connection_struct *conn,char *name,int max_connections)
DEBUG(3,("Yielding connection to %s\n",name));
ZERO_STRUCT(key);
- key.pid = getpid();
+ key.pid = sys_getpid();
if (conn) key.cnum = conn->cnum;
fstrcpy(key.name, name);
@@ -84,7 +84,7 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO
DEBUG(5,("claiming %s %d\n",name,max_connections));
ZERO_STRUCT(key);
- key.pid = getpid();
+ key.pid = sys_getpid();
key.cnum = conn?conn->cnum:-1;
fstrcpy(key.name, name);
@@ -94,7 +94,7 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO
/* fill in the crec */
ZERO_STRUCT(crec);
crec.magic = 0x280267;
- crec.pid = getpid();
+ crec.pid = sys_getpid();
crec.cnum = conn?conn->cnum:-1;
if (conn) {
crec.uid = conn->uid;
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index 8f8f17563e..2d83378b3d 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -205,7 +205,7 @@ ssize_t write_file(files_struct *fsp, char *data, SMB_OFF_T pos, size_t n)
if (LEVEL_II_OPLOCK_TYPE(fsp->oplock_type)) {
share_mode_entry *share_list = NULL;
- pid_t pid = getpid();
+ pid_t pid = sys_getpid();
int token = -1;
int num_share_modes = 0;
int i;
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index e644f52669..5b930f9940 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -55,7 +55,7 @@ files_struct *file_new(void )
increases the chance that the errant client will get an error rather
than causing corruption */
if (first_file == 0) {
- first_file = (getpid() ^ (int)time(NULL)) % real_max_open_files;
+ first_file = (sys_getpid() ^ (int)time(NULL)) % real_max_open_files;
}
i = bitmap_find(file_bmap, first_file);
diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c
index adef4a57f3..e8302a43e6 100644
--- a/source3/smbd/negprot.c
+++ b/source3/smbd/negprot.c
@@ -87,7 +87,7 @@ static int reply_lanman1(char *outbuf)
SSVAL(outbuf,smb_vwv4,1);
SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support
readbraw writebraw (possibly) */
- SIVAL(outbuf,smb_vwv6,getpid());
+ SIVAL(outbuf,smb_vwv6,sys_getpid());
SSVAL(outbuf,smb_vwv10, TimeDiff(t)/60);
put_dos_date(outbuf,smb_vwv8,t);
@@ -133,7 +133,7 @@ static int reply_lanman2(char *outbuf)
set_message(outbuf,13,crypt_len,True);
SSVAL(outbuf,smb_vwv1,secword);
- SIVAL(outbuf,smb_vwv6,getpid());
+ SIVAL(outbuf,smb_vwv6,sys_getpid());
if (doencrypt)
memcpy(smb_buf(outbuf), cryptkey, 8);
@@ -226,7 +226,7 @@ static int reply_nt1(char *outbuf)
SSVAL(outbuf,smb_vwv2+1,1); /* num vcs */
SIVAL(outbuf,smb_vwv3+1,0xffff); /* max buffer. LOTS! */
SIVAL(outbuf,smb_vwv5+1,0x10000); /* raw size. full 64k */
- SIVAL(outbuf,smb_vwv7+1,getpid()); /* session key */
+ SIVAL(outbuf,smb_vwv7+1,sys_getpid()); /* session key */
SIVAL(outbuf,smb_vwv9+1,capabilities); /* capabilities */
put_long_date(outbuf+smb_vwv11+1,t);
SSVALS(outbuf,smb_vwv15+1,TimeDiff(t)/60);
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 9aadb39bc9..0c6927ba2a 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -342,7 +342,7 @@ static int check_share_mode( share_mode_entry *share, int deny_mode,
{
int access_allowed = access_table(deny_mode,old_deny_mode,old_open_mode,
- (share->pid == getpid()),is_executable(fname));
+ (share->pid == sys_getpid()),is_executable(fname));
if ((access_allowed == AFAIL) ||
(!fcbopen && (access_allowed == AREAD && *flags == O_RDWR)) ||
@@ -946,7 +946,7 @@ BOOL check_file_sharing(connection_struct *conn,char *fname, BOOL rename_op)
share_mode_entry *old_shares = 0;
int num_share_modes;
SMB_STRUCT_STAT sbuf;
- pid_t pid = getpid();
+ pid_t pid = sys_getpid();
SMB_DEV_T dev;
SMB_INO_T inode;
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index 28ab29d027..4a363d45e9 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -111,7 +111,7 @@ address %lx. Error was %s\n", (long)htonl(INADDR_LOOPBACK), strerror(errno)));
return False;
DEBUG(3,("open_oplock ipc: pid = %d, global_oplock_port = %u\n",
- (int)getpid(), global_oplock_port));
+ (int)sys_getpid(), global_oplock_port));
return True;
}
@@ -1088,7 +1088,7 @@ BOOL request_oplock_break(share_mode_entry *share_entry,
{
char op_break_msg[OPLOCK_BREAK_MSG_LEN];
struct sockaddr_in addr_out;
- pid_t pid = getpid();
+ pid_t pid = sys_getpid();
time_t start_time;
int time_left;
long usec;
@@ -1342,7 +1342,7 @@ void check_kernel_oplocks(void)
set_process_capability(KERNEL_OPLOCK_CAPABILITY,True);
set_inherited_process_capability(KERNEL_OPLOCK_CAPABILITY,True);
- slprintf(tmpname,sizeof(tmpname)-1, "%s/koplock.%d", lp_lockdir(), (int)getpid());
+ slprintf(tmpname,sizeof(tmpname)-1, "%s/koplock.%d", lp_lockdir(), (int)sys_getpid());
if(pipe(pfd) != 0) {
DEBUG(0,("check_kernel_oplocks: Unable to create pipe. Error was %s\n",
diff --git a/source3/smbd/password.c b/source3/smbd/password.c
index f92d31718c..a8b9050030 100644
--- a/source3/smbd/password.c
+++ b/source3/smbd/password.c
@@ -53,8 +53,8 @@ void generate_next_challenge(char *challenge)
/* get a sort-of random number */
GetTimeOfDay(&tval);
- v1 = (counter++) + getpid() + tval.tv_sec;
- v2 = (counter++) * getpid() + tval.tv_usec;
+ v1 = (counter++) + sys_getpid() + tval.tv_sec;
+ v2 = (counter++) * sys_getpid() + tval.tv_usec;
SIVAL(challenge,0,v1);
SIVAL(challenge,4,v2);
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index b81e831133..1eb5899667 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -421,7 +421,7 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize
extern int global_smbpid;
if (pid == (pid_t)-1)
- pid = getpid();
+ pid = sys_getpid();
errno = 0;
last_message = type;
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 8e4de78cbf..574be64553 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -238,7 +238,7 @@ max can be %d\n",
continue;
}
- if (smbd_server_fd() != -1 && fork()==0) {
+ if (smbd_server_fd() != -1 && sys_fork()==0) {
/* Child code ... */
/* close the listening socket(s) */
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index 8e04f7e989..ebc4c9a790 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -608,7 +608,7 @@ connection_struct *make_connection(char *service,char *user,char *password, int
dbgtext( "connect to service %s ", lp_servicename(SNUM(conn)) );
dbgtext( "as user %s ", user );
dbgtext( "(uid=%d, gid=%d) ", (int)geteuid(), (int)getegid() );
- dbgtext( "(pid %d)\n", (int)getpid() );
+ dbgtext( "(pid %d)\n", (int)sys_getpid() );
}
/* we've finished with the sensitive stuff */