Author: jra Date: 2006-04-11 01:43:16 +0000 (Tue, 11 Apr 2006) New Revision: 15031
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15031 Log: On a performace hunt... Remove as many extraneous memset's as possible. Jeremy. Modified: trunk/source/lib/util.c trunk/source/lib/util_sock.c trunk/source/smbd/nttrans.c trunk/source/smbd/process.c trunk/source/smbd/reply.c trunk/source/smbd/trans2.c Changeset: Modified: trunk/source/lib/util.c =================================================================== --- trunk/source/lib/util.c 2006-04-11 01:43:13 UTC (rev 15030) +++ trunk/source/lib/util.c 2006-04-11 01:43:16 UTC (rev 15031) @@ -529,8 +529,9 @@ int set_message(char *buf,int num_words,int num_bytes,BOOL zero) { - if (zero) + if (zero && (num_words || num_bytes)) { memset(buf + smb_size,'\0',num_words*2 + num_bytes); + } SCVAL(buf,smb_wct,num_words); SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes); smb_setlen(buf,smb_size + num_words*2 + num_bytes - 4); Modified: trunk/source/lib/util_sock.c =================================================================== --- trunk/source/lib/util_sock.c 2006-04-11 01:43:13 UTC (rev 15030) +++ trunk/source/lib/util_sock.c 2006-04-11 01:43:16 UTC (rev 15031) @@ -662,8 +662,6 @@ smb_read_error = 0; - memset(buffer,'\0',smb_size + 100); - len = read_smb_length_return_keepalive(fd,buffer,timeout); if (len < 0) { DEBUG(10,("receive_smb_raw: length < 0!\n")); @@ -708,8 +706,9 @@ } if (ret != len) { - if (smb_read_error == 0) + if (smb_read_error == 0) { smb_read_error = READ_ERROR; + } return False; } Modified: trunk/source/smbd/nttrans.c =================================================================== --- trunk/source/smbd/nttrans.c 2006-04-11 01:43:13 UTC (rev 15030) +++ trunk/source/smbd/nttrans.c 2006-04-11 01:43:16 UTC (rev 15031) @@ -1805,7 +1805,7 @@ * update after a rename.. */ process_pending_change_notify_queue((time_t)0); - outsize = set_message(outbuf,0,0,True); + outsize = set_message(outbuf,0,0,False); END_PROFILE(SMBntrename); return(outsize); @@ -2956,7 +2956,7 @@ /* We need to send an interim response then receive the rest of the parameter/data bytes */ - outsize = set_message(outbuf,0,0,True); + outsize = set_message(outbuf,0,0,False); show_msg(outbuf); END_PROFILE(SMBnttrans); return outsize; Modified: trunk/source/smbd/process.c =================================================================== --- trunk/source/smbd/process.c 2006-04-11 01:43:13 UTC (rev 15030) +++ trunk/source/smbd/process.c 2006-04-11 01:43:16 UTC (rev 15031) @@ -1160,20 +1160,16 @@ void construct_reply_common(char *inbuf,char *outbuf) { - memset(outbuf,'\0',smb_size); - - set_message(outbuf,0,0,True); - SCVAL(outbuf,smb_com,CVAL(inbuf,smb_com)); + set_message(outbuf,0,0,False); - memcpy(outbuf+4,inbuf+4,4); - SCVAL(outbuf,smb_rcls,SMB_SUCCESS); - SCVAL(outbuf,smb_reh,0); + SCVAL(outbuf,smb_com,CVAL(inbuf,smb_com)); + SIVAL(outbuf,smb_rcls,0); SCVAL(outbuf,smb_flg, FLAG_REPLY | (CVAL(inbuf,smb_flg) & FLAG_CASELESS_PATHNAMES)); SSVAL(outbuf,smb_flg2, (SVAL(inbuf,smb_flg2) & FLAGS2_UNICODE_STRINGS) | common_flags2); + memset(outbuf+smb_pidhigh,'\0',(smb_tid-smb_pidhigh)); - SSVAL(outbuf,smb_err,SMB_SUCCESS); SSVAL(outbuf,smb_tid,SVAL(inbuf,smb_tid)); SSVAL(outbuf,smb_pid,SVAL(inbuf,smb_pid)); SSVAL(outbuf,smb_uid,SVAL(inbuf,smb_uid)); Modified: trunk/source/smbd/reply.c =================================================================== --- trunk/source/smbd/reply.c 2006-04-11 01:43:13 UTC (rev 15030) +++ trunk/source/smbd/reply.c 2006-04-11 01:43:16 UTC (rev 15031) @@ -848,7 +848,7 @@ return(UNIXERROR(ERRDOS,ERRbadpath)); } - outsize = set_message(outbuf,0,0,True); + outsize = set_message(outbuf,0,0,False); DEBUG(3,("chkpth %s mode=%d\n", name, (int)SVAL(inbuf,smb_vwv0))); END_PROFILE(SMBchkpth); @@ -994,7 +994,7 @@ return set_bad_path_error(errno, bad_path, outbuf, ERRDOS, ERRnoaccess); } - outsize = set_message(outbuf,0,0,True); + outsize = set_message(outbuf,0,0,False); DEBUG( 3, ( "setatr name=%s mode=%d\n", fname, mode ) ); @@ -2113,7 +2113,7 @@ */ process_pending_change_notify_queue((time_t)0); - outsize = set_message(outbuf,0,0,True); + outsize = set_message(outbuf,0,0,False); END_PROFILE(SMBunlink); return outsize; @@ -3214,7 +3214,7 @@ int reply_flush(connection_struct *conn, char *inbuf,char *outbuf, int size, int dum_buffsize) { - int outsize = set_message(outbuf,0,0,True); + int outsize = set_message(outbuf,0,0,False); uint16 fnum = SVAL(inbuf,smb_vwv0); files_struct *fsp = file_fsp(inbuf,smb_vwv0); START_PROFILE(SMBflush); @@ -3245,7 +3245,7 @@ file_close_pid(SVAL(inbuf,smb_pid),SVAL(inbuf,smb_uid)); - outsize = set_message(outbuf,0,0,True); + outsize = set_message(outbuf,0,0,False); DEBUG(3,("exit\n")); @@ -3266,7 +3266,7 @@ files_struct *fsp = NULL; START_PROFILE(SMBclose); - outsize = set_message(outbuf,0,0,True); + outsize = set_message(outbuf,0,0,False); /* If it's an IPC, pass off to the pipe handler. */ if (IS_IPC(conn)) { @@ -3414,7 +3414,7 @@ int reply_lock(connection_struct *conn, char *inbuf,char *outbuf, int length, int dum_buffsize) { - int outsize = set_message(outbuf,0,0,True); + int outsize = set_message(outbuf,0,0,False); SMB_BIG_UINT count,offset; NTSTATUS status; files_struct *fsp = file_fsp(inbuf,smb_vwv0); @@ -3476,7 +3476,7 @@ int reply_unlock(connection_struct *conn, char *inbuf,char *outbuf, int size, int dum_buffsize) { - int outsize = set_message(outbuf,0,0,True); + int outsize = set_message(outbuf,0,0,False); SMB_BIG_UINT count,offset; NTSTATUS status; files_struct *fsp = file_fsp(inbuf,smb_vwv0); @@ -3515,7 +3515,7 @@ int reply_tdis(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { - int outsize = set_message(outbuf,0,0,True); + int outsize = set_message(outbuf,0,0,False); uint16 vuid; START_PROFILE(SMBtdis); @@ -3622,7 +3622,7 @@ int reply_printclose(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { - int outsize = set_message(outbuf,0,0,True); + int outsize = set_message(outbuf,0,0,False); files_struct *fsp = file_fsp(inbuf,smb_vwv0); int close_err = 0; START_PROFILE(SMBsplclose); @@ -3727,7 +3727,7 @@ int reply_printwrite(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { int numtowrite; - int outsize = set_message(outbuf,0,0,True); + int outsize = set_message(outbuf,0,0,False); char *data; files_struct *fsp = file_fsp(inbuf,smb_vwv0); @@ -3852,7 +3852,7 @@ change_owner_to_parent(conn, NULL, directory, &sbuf); } - outsize = set_message(outbuf,0,0,True); + outsize = set_message(outbuf,0,0,False); DEBUG( 3, ( "mkdir %s ret=%d\n", directory, outsize ) ); @@ -4040,7 +4040,7 @@ return set_bad_path_error(errno, bad_path, outbuf, ERRDOS, ERRbadpath); } - outsize = set_message(outbuf,0,0,True); + outsize = set_message(outbuf,0,0,False); DEBUG( 3, ( "rmdir %s\n", directory ) ); @@ -4712,7 +4712,7 @@ * update after a rename.. */ process_pending_change_notify_queue((time_t)0); - outsize = set_message(outbuf,0,0,True); + outsize = set_message(outbuf,0,0,False); END_PROFILE(SMBmv); return(outsize); @@ -5043,7 +5043,7 @@ return ERROR_DOS(ERRDOS,ERRbadpath); } - outsize = set_message(outbuf,0,0,True); + outsize = set_message(outbuf,0,0,False); SCVAL(outbuf,smb_reh,CVAL(inbuf,smb_reh)); DEBUG(3,("setdir %s\n", newdir)); @@ -5542,7 +5542,7 @@ files_struct *fsp = file_fsp(inbuf,smb_vwv0); START_PROFILE(SMBsetattrE); - outsize = set_message(outbuf,0,0,True); + outsize = set_message(outbuf,0,0,False); if(!fsp || (fsp->conn != conn)) { END_PROFILE(SMBsetattrE); Modified: trunk/source/smbd/trans2.c =================================================================== --- trunk/source/smbd/trans2.c 2006-04-11 01:43:13 UTC (rev 15030) +++ trunk/source/smbd/trans2.c 2006-04-11 01:43:16 UTC (rev 15031) @@ -2410,7 +2410,11 @@ SBIG_UINT(pdata,4,((SMB_BIG_UINT)( CIFS_UNIX_POSIX_ACLS_CAP| CIFS_UNIX_POSIX_PATHNAMES_CAP| +#if defined(DEVELOPER) /* Not quite finished yet... */ CIFS_UNIX_FCNTL_LOCKS_CAP))); +#else + 0))); +#endif break; case SMB_QUERY_POSIX_FS_INFO: @@ -2526,9 +2530,11 @@ lp_set_posix_pathnames(); mangle_change_to_posix(); } +#if defined(DEVELOPER) if (client_unix_cap_low & CIFS_UNIX_FCNTL_LOCKS_CAP) { lp_set_posix_cifsx_locktype(POSIX_LOCK); } +#endif break; } case SMB_FS_QUOTA_INFORMATION: @@ -2961,6 +2967,7 @@ } break; } +#if defined(DEVELOPER) case SMB_QUERY_POSIX_LOCK: { if (fsp == NULL || fsp->fh->fd == -1) { @@ -2982,6 +2989,7 @@ return ERROR_NT(NT_STATUS_NO_MEMORY); } } +#endif default: break; } @@ -3511,6 +3519,8 @@ } #endif + +#if defined(DEVELOPER) case SMB_QUERY_POSIX_LOCK: { NTSTATUS status = NT_STATUS_INVALID_LEVEL; @@ -3583,6 +3593,7 @@ } break; } +#endif default: return ERROR_NT(NT_STATUS_INVALID_LEVEL); @@ -4453,6 +4464,7 @@ } #endif +#if defined(DEVELOPER) case SMB_SET_POSIX_LOCK: { SMB_BIG_UINT count; @@ -4551,6 +4563,7 @@ send_trans2_replies(outbuf, bufsize, params, 2, *ppdata, 0); return(-1); } +#endif default: return ERROR_NT(NT_STATUS_INVALID_LEVEL); @@ -4947,7 +4960,7 @@ dptr_close(&dptr_num); - outsize = set_message(outbuf,0,0,True); + outsize = set_message(outbuf,0,0,False); DEBUG(3,("SMBfindclose dptr_num = %d\n", dptr_num)); @@ -4974,7 +4987,7 @@ findnotifyfirst - so any dptr_num is ok here. Just ignore it. */ - outsize = set_message(outbuf,0,0,True); + outsize = set_message(outbuf,0,0,False); DEBUG(3,("SMB_findnclose dptr_num = %d\n", dptr_num)); @@ -5261,7 +5274,7 @@ /* We need to send an interim response then receive the rest of the parameter/data bytes */ - outsize = set_message(outbuf,0,0,True); + outsize = set_message(outbuf,0,0,False); show_msg(outbuf); END_PROFILE(SMBtrans2); return outsize;