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
831ac95f
Unverified
Commit
831ac95f
authored
Feb 23, 2019
by
Constantin Rack
Committed by
GitHub
Feb 23, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3428 from Eelis/mallocfail
Don't crash if memory allocation in socket_poller_t::rebuild fails.
parents
f8bcdaf1
8259c519
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
6 deletions
+18
-6
zmq_poller.txt
doc/zmq_poller.txt
+2
-0
socket_poller.cpp
src/socket_poller.cpp
+15
-5
socket_poller.hpp
src/socket_poller.hpp
+1
-1
No files found.
doc/zmq_poller.txt
View file @
831ac95f
...
...
@@ -223,6 +223,8 @@ On _zmq_poller_add_fd_, _zmq_poller_modify_fd_ and _zmq_poller_remove_fd_:
The _fd_ specified was the retired fd.
On _zmq_poller_wait_ and _zmq_poller_wait_all_:
*ENOMEM*::
Necessary resources could not be allocated.
*ETERM*::
At least one of the registered objects is a 'socket' whose associated 0MQ
'context' was terminated.
...
...
src/socket_poller.cpp
View file @
831ac95f
...
...
@@ -260,7 +260,7 @@ int zmq::socket_poller_t::remove_fd (fd_t fd_)
return
0
;
}
void
zmq
::
socket_poller_t
::
rebuild
()
int
zmq
::
socket_poller_t
::
rebuild
()
{
_use_signaler
=
false
;
_pollset_size
=
0
;
...
...
@@ -287,10 +287,15 @@ void zmq::socket_poller_t::rebuild ()
}
if
(
_pollset_size
==
0
)
return
;
return
0
;
_pollfds
=
static_cast
<
pollfd
*>
(
malloc
(
_pollset_size
*
sizeof
(
pollfd
)));
alloc_assert
(
_pollfds
);
if
(
!
_pollfds
)
{
errno
=
ENOMEM
;
_need_rebuild
=
true
;
return
-
1
;
}
int
item_nbr
=
0
;
...
...
@@ -390,6 +395,8 @@ void zmq::socket_poller_t::rebuild ()
}
#endif
return
0
;
}
void
zmq
::
socket_poller_t
::
zero_trail_events
(
...
...
@@ -523,8 +530,11 @@ int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_,
return
-
1
;
}
if
(
_need_rebuild
)
rebuild
();
if
(
_need_rebuild
)
{
int
rc
=
rebuild
();
if
(
rc
==
-
1
)
return
-
1
;
}
if
(
unlikely
(
_pollset_size
==
0
))
{
// We'll report an error (timed out) as if the list was non-empty and
...
...
src/socket_poller.hpp
View file @
831ac95f
...
...
@@ -101,7 +101,7 @@ class socket_poller_t
uint64_t
&
now_
,
uint64_t
&
end_
,
bool
&
first_pass_
);
void
rebuild
();
int
rebuild
();
// Used to check whether the object is a socket_poller.
uint32_t
_tag
;
...
...
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