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
4de8781f
Commit
4de8781f
authored
Aug 04, 2020
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
0e8f3d9a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
bench_client.vcxproj.user
examples/bench_client/bench_client.vcxproj.user
+4
-0
server_demo_libevent.cpp
examples/server_demo_libevent/server_demo_libevent.cpp
+7
-7
No files found.
examples/bench_client/bench_client.vcxproj.user
View file @
4de8781f
...
...
@@ -4,4 +4,8 @@
<LocalDebuggerCommandArguments>
192.168.1.166 12345 6 6000 50
</LocalDebuggerCommandArguments>
<DebuggerFlavor>
WindowsLocalDebugger
</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<LocalDebuggerCommandArguments>
192.168.1.166 12345 6 6000 50
</LocalDebuggerCommandArguments>
<DebuggerFlavor>
WindowsLocalDebugger
</DebuggerFlavor>
</PropertyGroup>
</Project>
\ No newline at end of file
examples/server_demo_libevent/server_demo_libevent.cpp
View file @
4de8781f
...
...
@@ -246,6 +246,7 @@ void readcb(struct bufferevent* bev, void* user_data)
{
auto
input
=
bufferevent_get_input
(
bev
);
auto
context
=
(
ThreadContext
*
)
user_data
;
std
::
lock_guard
<
std
::
mutex
>
lg
(
context
->
mutex
);
while
(
1
)
{
size_t
len
=
evbuffer_get_length
(
input
);
...
...
@@ -304,6 +305,7 @@ void accept_cb(evconnlistener* listener, evutil_socket_t fd, sockaddr* addr, int
static
int
worker_id
=
0
;
auto
context
=
worker_thread_contexts
[
worker_id
];
std
::
lock_guard
<
std
::
mutex
>
lg
(
context
->
mutex
);
auto
bev
=
bufferevent_socket_new
(
context
->
base
,
fd
,
BEV_OPT_CLOSE_ON_FREE
);
if
(
!
bev
)
{
fprintf
(
stderr
,
"Error constructing bufferevent!
\n
"
);
...
...
@@ -314,11 +316,7 @@ void accept_cb(evconnlistener* listener, evutil_socket_t fd, sockaddr* addr, int
Client
client
;
client
.
fd
=
(
int
)
fd
;
client
.
output
=
bufferevent_get_output
(
bev
);
{
std
::
lock_guard
<
std
::
mutex
>
lg
(
context
->
mutex
);
context
->
clients
[(
int
)
fd
]
=
client
;
}
context
->
clients
[(
int
)
fd
]
=
client
;
bufferevent_setcb
(
bev
,
readcb
,
nullptr
,
eventcb
,
context
);
bufferevent_enable
(
bev
,
EV_WRITE
|
EV_READ
);
...
...
@@ -442,8 +440,10 @@ int main(int argc, char** argv)
}));
}
init_listener_thread
(
sin
);
std
::
thread
listener_thread
([]()
{
event_base_dispatch
(
listen_thread_evbase
);
});
std
::
thread
listener_thread
([
&
sin
]()
{
init_listener_thread
(
sin
);
event_base_dispatch
(
listen_thread_evbase
);
});
op_usage
();
...
...
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