-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d24e7e6
commit 87d96e0
Showing
1 changed file
with
22 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2003-2020 Ke Hengzhong <[email protected]> | ||
* Copyright (c) 2003-2024 Ke Hengzhong <[email protected]> | ||
* All rights reserved. | ||
*/ | ||
|
||
|
@@ -45,21 +45,29 @@ int main (int argc, char ** argv) | |
signal(SIGTERM, signal_handler); /* catch kill signal */ | ||
signal(SIGINT, signal_handler); /* catch SIGINT signal */ | ||
|
||
gpcore = pcore = epcore_new(65536, 1); | ||
if (argc > 1 && argv[1]) | ||
listenport = (int)strtol(argv[1], NULL, 10); | ||
if (listenport < 10 || listenport > 65535) | ||
listenport = 8080; | ||
|
||
gpcore = pcore = epcore_new(65536); | ||
|
||
/* do some initialization */ | ||
mlisten = eptcp_mlisten(pcore, NULL, listenport, NULL, echo_pump, pcore); | ||
mlisten = eptcp_mlisten(pcore, NULL, listenport, | ||
NULL, /* socket option */ | ||
NULL, /* given listen-device parameter */ | ||
echo_pump, pcore); | ||
if (!mlisten) goto exit; | ||
|
||
printf("EchoSrv TCP Port: %d being listened\n\n", listenport); | ||
|
||
iotimer_start(pcore, 90*1000, 1001, NULL, echo_pump, pcore); | ||
iotimer_start(pcore, 90*1000, 1001, NULL, echo_pump, pcore, 0); | ||
|
||
/* start 2 worker threads */ | ||
epcore_start_worker(pcore, 2); | ||
//epcore_start_worker(pcore, 2); | ||
|
||
/* start 1 epump threads */ | ||
epcore_start_epump(pcore, 1); | ||
/* start 2 epump threads */ | ||
epcore_start_epump(pcore, 2); | ||
|
||
/* main thread executing the epump_main_proc as an epump thread */ | ||
epump_main_start(pcore, 0); | ||
|
@@ -91,7 +99,11 @@ int echo_pump (void * vpcore, void * vobj, int event, int fdtype) | |
return -1; | ||
|
||
while (1) { | ||
pdev = eptcp_accept(iodev_epcore(vobj), vobj, NULL, &ret, echo_pump, pcore, BIND_ONE_EPUMP); | ||
pdev = eptcp_accept(iodev_epcore(vobj), vobj, | ||
NULL, /* socket option */ | ||
NULL, /* accepted device parameter */ | ||
echo_pump, pcore, BIND_ONE_EPUMP, | ||
0, &ret); | ||
if (!pdev) break; | ||
|
||
printf("\nThreadID=%lu, ListenFD=%d EPumpID=%lu WorkerID=%lu " | ||
|
@@ -136,8 +148,8 @@ int echo_pump (void * vpcore, void * vobj, int event, int fdtype) | |
printf("\nThreadID=%lu IOTimerID=%lu EPumpID=%lu timeout, curtick=%lu\n", | ||
get_threadid(), iotimer_id(vobj), | ||
epumpid(iotimer_epump(vobj)), time(0)); | ||
epcore_print(pcore); | ||
iotimer_start(pcore, 90*1000, 1001, NULL, echo_pump, pcore); | ||
epcore_print(pcore, NULL, stdout); | ||
iotimer_start(pcore, 90*1000, 1001, NULL, echo_pump, pcore, 0); | ||
} | ||
break; | ||
|
||
|