@@ -1012,7 +1012,6 @@ static void usage(int argc, char *argv[])
10121012 acl_msg_info ("usage: %s -h[help]"
10131013 " -c [use chroot]"
10141014 " -d [debug]"
1015- " -l [run alone]"
10161015 " -n service_name"
10171016 " -s socket_count"
10181017 " -i [use stdin]"
@@ -1222,7 +1221,7 @@ static void server_main(int argc, char **argv, va_list ap)
12221221{
12231222 const char * myname = "acl_aio_server_main" ;
12241223 ACL_VSTREAM * stream = 0 ;
1225- int key , f_flag = 0 , alone = 0 ;
1224+ int key , f_flag = 0 ;
12261225 char * root_dir = 0 , * user_name = 0 ;
12271226 char * service_name = acl_mystrdup (acl_safe_basename (argv [0 ]));
12281227 ACL_MASTER_SERVER_INIT_FN pre_init = 0 ;
@@ -1254,7 +1253,7 @@ static void server_main(int argc, char **argv, va_list ap)
12541253
12551254 opterr = 0 ;
12561255
1257- while ((key = getopt (argc , argv , "hcdlm :n:o:s:it:uvzf:" )) > 0 ) {
1256+ while ((key = getopt (argc , argv , "hcdm :n:o:s:it:uvzf:" )) > 0 ) {
12581257 switch (key ) {
12591258 case 'h' :
12601259 usage (argc , argv );
@@ -1267,9 +1266,6 @@ static void server_main(int argc, char **argv, va_list ap)
12671266 case 'c' :
12681267 root_dir = "setme" ;
12691268 break ;
1270- case 'l' :
1271- alone = 1 ;
1272- break ;
12731269 case 'n' :
12741270 service_name = optarg ;
12751271 break ;
@@ -1387,6 +1383,10 @@ static void server_main(int argc, char **argv, va_list ap)
13871383 acl_msg_fatal ("chdir(\"%s\"): %s" , acl_var_aio_queue_dir ,
13881384 acl_last_serror ());
13891385
1386+ /* 增加 ip 地址限制 */
1387+ if (acl_var_aio_access_allow && * acl_var_aio_access_allow )
1388+ acl_access_add (acl_var_aio_access_allow , ", \t" , ":" );
1389+
13901390 /* Run pre-jail initialization. */
13911391 if (pre_init )
13921392 pre_init (__service_ctx );
@@ -1437,4 +1437,58 @@ void acl_aio_server2_main(int argc, char **argv, ACL_AIO_SERVER2_FN service,...)
14371437 server_main (argc , argv , ap );
14381438}
14391439
1440+ /****************************************************************************/
1441+
1442+ static ACL_AIO_RUN_FN __app_run ;
1443+
1444+ static void service_adapter (ACL_ASTREAM * astream , void * ctx )
1445+ {
1446+ const char * myname = "service_adapter" ;
1447+
1448+ if (__app_run ) {
1449+ if (__app_run (astream , ctx ) != 0 )
1450+ acl_aio_iocp_close (astream );
1451+ } else
1452+ acl_msg_error ("%s(%d): __app_run null" , myname , __LINE__ );
1453+ }
1454+
1455+ void acl_aio_app_main (int argc , char * argv [], ACL_AIO_RUN_FN run_fn ,
1456+ void * run_ctx , ...)
1457+ {
1458+ va_list ap ;
1459+
1460+ va_start (ap , run_ctx );
1461+ __service_main = service_adapter ;
1462+ __app_run = run_fn ;
1463+ __service_ctx = run_ctx ;
1464+
1465+ server_main (argc , argv , ap );
1466+ }
1467+
1468+ static ACL_AIO_RUN2_FN __app2_run ;
1469+
1470+ static void service_adapter2 (ACL_SOCKET fd , void * ctx )
1471+ {
1472+ const char * myname = "service_adapter" ;
1473+
1474+ if (__app2_run ) {
1475+ if (__app2_run (fd , ctx ) != 0 )
1476+ acl_socket_close (fd );
1477+ } else
1478+ acl_msg_error ("%s(%d): __app2_run null" , myname , __LINE__ );
1479+ }
1480+
1481+ void acl_aio_app2_main (int argc , char * argv [], ACL_AIO_RUN2_FN run2_fn ,
1482+ void * run_ctx , ...)
1483+ {
1484+ va_list ap ;
1485+
1486+ va_start (ap , run_ctx );
1487+ __service2_main = service_adapter2 ;
1488+ __app2_run = run2_fn ;
1489+ __service_ctx = run_ctx ;
1490+
1491+ server_main (argc , argv , ap );
1492+ }
1493+
14401494#endif /* ACL_UNIX */
0 commit comments