segfault caused by a log_info... no more segfault.
This commit is contained in:
parent
63ac24c050
commit
af3e1122b5
|
@ -121,7 +121,7 @@ int p7_fdinit(p7_handle_t **handle, int active, int check,
|
|||
const char *name, int readfd, int writefd);
|
||||
|
||||
/* De-initialization */
|
||||
void p7_exit(p7_handle_t *handle, int term, int free);
|
||||
void p7_exit(p7_handle_t *handle, int term);
|
||||
/* ************************************************************************** */
|
||||
/* Protocol */
|
||||
/* ************************************************************************** */
|
||||
|
|
|
@ -108,6 +108,9 @@ int p7_command_is_supported(unsigned int code, const p7_env_t *env);
|
|||
/* ************************************************************************** */
|
||||
/* main structure */
|
||||
struct p7_handle_s {
|
||||
/* was allocated */
|
||||
int _wasalloc;
|
||||
|
||||
/* stream */
|
||||
p7_stream_t *_stream;
|
||||
p7_stream_t _stream_data;
|
||||
|
|
|
@ -143,6 +143,7 @@ int p7_sinit(p7_handle_t **h, int active, int check,
|
|||
/* initialize handle */
|
||||
p7_handle_t *handle = *h;
|
||||
bzero(handle, sizeof(p7_handle_t));
|
||||
handle->_wasalloc = alloc;
|
||||
handle->_stream_data = dstream;
|
||||
handle->_stream = &handle->_stream_data;
|
||||
handle->_response = &handle->_response_data;
|
||||
|
@ -183,7 +184,7 @@ int p7_sinit(p7_handle_t **h, int active, int check,
|
|||
/* initialization went alright */
|
||||
return (0);
|
||||
fail:
|
||||
p7_exit(*h, 0, alloc);
|
||||
p7_exit(*h, 0);
|
||||
*h = NULL;
|
||||
return (err);
|
||||
}
|
||||
|
@ -200,7 +201,7 @@ fail:
|
|||
* @arg wasalloc should we free the handle?
|
||||
*/
|
||||
|
||||
void p7_exit(p7_handle_t *handle, int term, int wasalloc)
|
||||
void p7_exit(p7_handle_t *handle, int term)
|
||||
{
|
||||
log_info("exit is called.");
|
||||
/* check if handle is already freed */
|
||||
|
@ -220,6 +221,6 @@ void p7_exit(p7_handle_t *handle, int term, int wasalloc)
|
|||
(*handle->_stream->close)(handle->_stream->cookie);
|
||||
|
||||
/* free handle */
|
||||
if (wasalloc) free(handle);
|
||||
log_info("handle is freeeeeeeeed :D");
|
||||
log_info("freeing the handle!");
|
||||
if (handle->_wasalloc) free(handle);
|
||||
}
|
||||
|
|
Reference in New Issue