Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ademco_hb
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
ademco_hb
Commits
6fac5903
Commit
6fac5903
authored
Jul 31, 2020
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update tools
parent
b624bcf6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
3 deletions
+1
-3
server_demo_libevent.cpp
examples/server_demo_libevent/server_demo_libevent.cpp
+1
-3
No files found.
examples/server_demo_libevent/server_demo_libevent.cpp
View file @
6fac5903
...
...
@@ -264,11 +264,9 @@ void accept_cb(evconnlistener* listener, evutil_socket_t fd, sockaddr* addr, int
auto
sin
=
(
sockaddr_in
*
)
addr
;
inet_ntop
(
AF_INET
,
&
sin
->
sin_addr
,
str
,
INET_ADDRSTRLEN
);
printf
(
"accpet TCP connection #%d from: %s:%d
\n
"
,
(
int
)
fd
,
str
,
sin
->
sin_port
);
evutil_make_socket_nonblocking
(
fd
);
static
int
worker_id
=
0
;
auto
context
=
worker_thread_contexts
[
worker_id
];
auto
bev
=
bufferevent_socket_new
(
context
->
base
,
fd
,
BEV_OPT_CLOSE_ON_FREE
);
if
(
!
bev
)
{
...
...
@@ -276,6 +274,7 @@ void accept_cb(evconnlistener* listener, evutil_socket_t fd, sockaddr* addr, int
event_base_loopbreak
(
context
->
base
);
return
;
}
Client
client
;
client
.
fd
=
(
int
)
fd
;
client
.
output
=
bufferevent_get_output
(
bev
);
...
...
@@ -287,7 +286,6 @@ void accept_cb(evconnlistener* listener, evutil_socket_t fd, sockaddr* addr, int
bufferevent_setcb
(
bev
,
readcb
,
nullptr
,
eventcb
,
context
);
bufferevent_enable
(
bev
,
EV_WRITE
|
EV_READ
);
worker_id
=
(
++
worker_id
)
%
thread_count
;
}
...
...
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