Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
5fead473
Commit
5fead473
authored
Jul 22, 2015
by
Joe Eli McIlvain
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1482 from brian-peloton/master
Fix memory leak when creating a socket fails.
parents
c05a475b
773a06fc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
16 deletions
+28
-16
signaler.cpp
src/signaler.cpp
+24
-15
socket_base.cpp
src/socket_base.cpp
+4
-1
No files found.
src/signaler.cpp
View file @
5fead473
...
...
@@ -133,28 +133,37 @@ zmq::signaler_t::signaler_t ()
#endif
}
// This might get run after some part of construction failed, leaving one or
// both of r and w retired_fd.
zmq
::
signaler_t
::~
signaler_t
()
{
#if defined ZMQ_HAVE_EVENTFD
if
(
r
==
retired_fd
)
return
;
int
rc
=
close_wait_ms
(
r
);
errno_assert
(
rc
==
0
);
#elif defined ZMQ_HAVE_WINDOWS
const
struct
linger
so_linger
=
{
1
,
0
};
int
rc
=
setsockopt
(
w
,
SOL_SOCKET
,
SO_LINGER
,
(
const
char
*
)
&
so_linger
,
sizeof
so_linger
);
// Only check shutdown if WSASTARTUP was previously done
if
(
rc
==
0
||
WSAGetLastError
()
!=
WSANOTINITIALISED
)
{
wsa_assert
(
rc
!=
SOCKET_ERROR
);
rc
=
closesocket
(
w
);
wsa_assert
(
rc
!=
SOCKET_ERROR
);
rc
=
closesocket
(
r
);
wsa_assert
(
rc
!=
SOCKET_ERROR
);
}
if
(
w
!=
retired_fd
)
{
const
struct
linger
so_linger
=
{
1
,
0
};
int
rc
=
setsockopt
(
w
,
SOL_SOCKET
,
SO_LINGER
,
(
const
char
*
)
&
so_linger
,
sizeof
so_linger
);
// Only check shutdown if WSASTARTUP was previously done
if
(
rc
==
0
||
WSAGetLastError
()
!=
WSANOTINITIALISED
)
{
wsa_assert
(
rc
!=
SOCKET_ERROR
);
rc
=
closesocket
(
w
);
wsa_assert
(
rc
!=
SOCKET_ERROR
);
if
(
r
==
retired_fd
)
return
;
rc
=
closesocket
(
r
);
wsa_assert
(
rc
!=
SOCKET_ERROR
);
}
#else
int
rc
=
close_wait_ms
(
w
);
errno_assert
(
rc
==
0
);
rc
=
close_wait_ms
(
r
);
errno_assert
(
rc
==
0
);
if
(
w
!=
retired_fd
)
{
int
rc
=
close_wait_ms
(
w
);
errno_assert
(
rc
==
0
);
}
if
(
r
!=
retired_fd
)
{
rc
=
close_wait_ms
(
r
);
errno_assert
(
rc
==
0
);
}
#endif
}
...
...
src/socket_base.cpp
View file @
5fead473
...
...
@@ -154,8 +154,11 @@ zmq::socket_base_t *zmq::socket_base_t::create (int type_, class ctx_t *parent_,
mailbox_t
*
mailbox
=
dynamic_cast
<
mailbox_t
*>
(
s
->
mailbox
);
if
(
mailbox
!=
NULL
&&
mailbox
->
get_fd
()
==
retired_fd
)
if
(
mailbox
!=
NULL
&&
mailbox
->
get_fd
()
==
retired_fd
)
{
s
->
destroyed
=
true
;
delete
s
;
return
NULL
;
}
return
s
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment