Skip to content
Snippets Groups Projects
Commit 53d0ec5b authored by rswindell's avatar rswindell
Browse files

Eliminate smb_stack(), SMB_STACK_* as this implementation is non-thread-safe

and frankly could cause all kinds of havok with multiple thread (e.g. nodes)
pushing and popping SMB's concurrently. eek.
parent 91135141
Branches
Tags
No related merge requests found
......@@ -239,57 +239,6 @@ BOOL SMBCALL smb_islocked(smb_t* smb)
return(TRUE);
}
/****************************************************************************/
/* If the parameter 'push' is non-zero, this function stores the currently */
/* open message base to the "virtual" smb stack. Up to SMB_STACK_LEN */
/* message bases may be stored (defined in SMBDEFS.H). */
/* The parameter 'op' is the operation to perform on the stack. Either */
/* SMB_STACK_PUSH, SMB_STACK_POP, or SMB_STACK_XCHNG */
/* If the operation is SMB_STACK_POP, this function restores a message base */
/* previously saved with a SMB_STACK_PUSH call to this same function. */
/* If the operation is SMB_STACK_XCHNG, then the current message base is */
/* exchanged with the message base on the top of the stack (most recently */
/* pushed. */
/* If the current message base is not open, the SMB_STACK_PUSH and */
/* SMB_STACK_XCHNG operations do nothing */
/* Returns 0 on success, non-zero if stack full. */
/* If operation is SMB_STACK_POP or SMB_STACK_XCHNG, it always returns 0. */
/****************************************************************************/
int SMBCALL smb_stack(smb_t* smb, int op)
{
static smb_t stack[SMB_STACK_LEN];
static int stack_idx;
smb_t tmp_smb;
if(op==SMB_STACK_PUSH) {
if(stack_idx>=SMB_STACK_LEN) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s SMB stack overflow", __FUNCTION__);
return(SMB_FAILURE);
}
if(smb->shd_fp==NULL || smb->sdt_fp==NULL || smb->sid_fp==NULL)
return(SMB_SUCCESS); /* Msg base not open, do nothing */
memcpy(&stack[stack_idx],smb,sizeof(smb_t));
stack_idx++;
return(SMB_SUCCESS);
}
/* pop or xchng */
if(!stack_idx) /* Nothing on the stack, so do nothing */
return(SMB_SUCCESS);
if(op==SMB_STACK_XCHNG) {
if(smb->shd_fp==NULL)
return(SMB_SUCCESS);
memcpy(&tmp_smb,smb,sizeof(smb_t));
}
stack_idx--;
memcpy(smb,&stack[stack_idx],sizeof(smb_t));
if(op==SMB_STACK_XCHNG) {
memcpy(&stack[stack_idx],&tmp_smb,sizeof(smb_t));
stack_idx++;
}
return(SMB_SUCCESS);
}
/****************************************************************************/
/* Truncates header file */
/* Retries for smb.retry_time number of seconds */
......
......@@ -97,11 +97,6 @@
#define SMB_CLOSED 2 /* Poll/thread is closed to replies/votes */
#define SMB_UNAUTHORIZED 3 /* Poll was posted by someone else */
#define SMB_STACK_LEN 4 /* Max msg bases in smb_stack() */
#define SMB_STACK_POP 0 /* Pop a msg base off of smb_stack()*/
#define SMB_STACK_PUSH 1 /* Push a msg base onto smb_stack() */
#define SMB_STACK_XCHNG 2 /* Exchange msg base w/last pushed */
#define SMB_ALL_REFS 0 /* Free all references to data */
#define GETMSGTXT_TAILS (1<<0) /* Get message tail(s) */
......@@ -135,7 +130,6 @@ SMBEXPORT int SMBCALL smb_open_index(smb_t* smb);
SMBEXPORT void SMBCALL smb_close(smb_t* smb);
SMBEXPORT int SMBCALL smb_initsmbhdr(smb_t* smb);
SMBEXPORT int SMBCALL smb_create(smb_t* smb);
SMBEXPORT int SMBCALL smb_stack(smb_t* smb, int op);
SMBEXPORT int SMBCALL smb_trunchdr(smb_t* smb);
SMBEXPORT int SMBCALL smb_lock(smb_t* smb);
SMBEXPORT int SMBCALL smb_unlock(smb_t* smb);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment