[core] bugfix with memleak on stream close and unexpected link broken;
This commit is contained in:
parent
e8657b93c2
commit
9097e86604
@ -941,6 +941,7 @@ int _builtin_stream_close(void *m, sexp_t *sx)
|
|||||||
if(stream->pin_channelid == channel->cid) {
|
if(stream->pin_channelid == channel->cid) {
|
||||||
r = SXE_SUCCESS;
|
r = SXE_SUCCESS;
|
||||||
r = stream->desc->ops->s_close(stream);
|
r = stream->desc->ops->s_close(stream);
|
||||||
|
if(r == SXE_SUCCESS) __free_stream(link, stream);
|
||||||
} else r = SXE_EPERM;
|
} else r = SXE_EPERM;
|
||||||
} else r = SXE_NOSUCHSTREAMTYPE;
|
} else r = SXE_NOSUCHSTREAMTYPE;
|
||||||
|
|
||||||
|
@ -485,6 +485,24 @@ static void __link_minimal_free(sxlink_t *co)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void __link_close_streams(sxlink_t *link)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
struct sxstream_opened *stream;
|
||||||
|
|
||||||
|
if(!link->streams) return;
|
||||||
|
|
||||||
|
for(i = 0; i < MAX_STREAMSOPENED; i++) {
|
||||||
|
if(link->streams[i]) {
|
||||||
|
stream = link->streams[i];
|
||||||
|
stream->desc->ops->s_close(stream);
|
||||||
|
free(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
static int __eval_sysrpc(sxlink_t *link, sexp_t *sx, int builtin)
|
static int __eval_sysrpc(sxlink_t *link, sexp_t *sx, int builtin)
|
||||||
{
|
{
|
||||||
sxl_rpclist_t *rpc_list;
|
sxl_rpclist_t *rpc_list;
|
||||||
@ -629,6 +647,7 @@ static void __link_destroy(sxlink_t *l)
|
|||||||
ERR_free_strings();
|
ERR_free_strings();
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
__link_close_streams(l);
|
||||||
__link_second_free(l);
|
__link_second_free(l);
|
||||||
__link_minimal_free(l);
|
__link_minimal_free(l);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user