Skip to content
Snippets Groups Projects
Commit 9391ac78 authored by rswindell's avatar rswindell
Browse files

smb_open_sub() will now create the msgbase if hasn't been created yet.

I noticed that more than one caller of smb_open_sub() would not call
smb_create() if the sub had not been previously "created" and in some of the
instances where they did call smb_create(), if create failed, the message base
was errorneously left open. So just do the create here to elmiinate the chance
of error (forgetting) and redundancy of logic.
parent 6ab65441
No related branches found
No related tags found
No related merge requests found
...@@ -1127,6 +1127,8 @@ int DLLCALL smb_storage_mode(scfg_t* cfg, smb_t* smb) ...@@ -1127,6 +1127,8 @@ int DLLCALL smb_storage_mode(scfg_t* cfg, smb_t* smb)
return SMB_SELFPACK; return SMB_SELFPACK;
} }
/* Open Synchronet Message Base and create, if necessary (e.g. first time opened) */
/* If return value is not SMB_SUCCESS, sub-board is not left open */
int DLLCALL smb_open_sub(scfg_t* cfg, smb_t* smb, unsigned int subnum) int DLLCALL smb_open_sub(scfg_t* cfg, smb_t* smb, unsigned int subnum)
{ {
int retval; int retval;
...@@ -1148,8 +1150,13 @@ int DLLCALL smb_open_sub(scfg_t* cfg, smb_t* smb, unsigned int subnum) ...@@ -1148,8 +1150,13 @@ int DLLCALL smb_open_sub(scfg_t* cfg, smb_t* smb, unsigned int subnum)
smb->status.attr = cfg->sub[subnum]->misc&SUB_HYPER ? SMB_HYPERALLOC :0; smb->status.attr = cfg->sub[subnum]->misc&SUB_HYPER ? SMB_HYPERALLOC :0;
} }
smb->retry_time = cfg->smb_retry_time; smb->retry_time = cfg->smb_retry_time;
if((retval = smb_open(smb)) == SMB_SUCCESS) if((retval = smb_open(smb)) == SMB_SUCCESS) {
smb->subnum = subnum; if(filelength(fileno(smb->shd_fp)) < sizeof(smbhdr_t) + sizeof(smb->status)) {
if((retval = smb_create(smb)) != SMB_SUCCESS)
smb_close(smb);
}
if(retval == SMB_SUCCESS)
smb->subnum = subnum;
}
return retval; return retval;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment