• R/O
  • HTTP
  • SSH
  • HTTPS

ultramonkey-l7-v2: コミット

UltraMonkey-L7 V2(single-thread implementation)


コミットメタ情報

リビジョンbcce9bd8ca8515694bc8c35f91fde115920aad66 (tree)
日時2010-06-08 01:36:29
作者Kohei TANUMA <tanuma@user...>
コミッターKohei TANUMA

ログメッセージ

Persist sorry server connection.
Change about sorry server connection to the following.
(a) 1. First connection: sorry server (over max connections)

    1. Communicate to sorry server...
    2. Some other connections done. (below max connections)
    3. Still communicate to sorry server.

(b) 1. First connection: sorry server (force-sorry-flag is on)

    1. Communicate to sorry server...
    2. Administrator change setting (force-sorry-flag is off)
    3. Still communicate to sorry server.

(c) 1. First connection: sorry server (no real servers)

    1. Communicate to sorry server...
    2. Administrator add real servers
    3. Still communicate to sorry server.

(d) 1. First connection: real server

    1. Communicate to real server...
    2. Administrator change setting (force-sorry-flag is on)
    3. Connection to real server will be disconnected.

(e) 1. First connection: real server

    1. Communicate to real server...
    2. Administrator remove real servers.
    3. Connection to real server will be disconnected.

変更サマリ

差分

--- a/include/l7vs_conn.h
+++ b/include/l7vs_conn.h
@@ -74,7 +74,6 @@ struct l7vs_conn{
7474 size_t cldata_bufsize; //! client buffer size
7575 int cmss; //! cmess??
7676 int sorry_conn_flag; //! sorry connection flag
77- struct l7vs_dest* old_dest; //! old destination
7877 };
7978
8079 //
@@ -136,7 +135,6 @@ inline void l7vs_conn_c_str(char* ret, const struct l7vs_conn* conn)
136135 char raddr_str[DEBUG_STR_LEN];
137136 char ciom_str[DEBUG_STR_LEN];
138137 char riom_str[DEBUG_STR_LEN];
139- char old_dest_str[DEBUG_STR_LEN];
140138
141139 if (!conn) {
142140 snprintf(ret, DEBUG_STR_LEN, "(nil)");
@@ -148,7 +146,6 @@ inline void l7vs_conn_c_str(char* ret, const struct l7vs_conn* conn)
148146 l7vs_dest_c_str(dest_str, conn->dest);
149147 l7vs_iomux_c_str(ciom_str, conn->ciom);
150148 l7vs_iomux_c_str(riom_str, conn->riom);
151- l7vs_dest_c_str(old_dest_str, conn->old_dest);
152149
153150 snprintf(ret, DEBUG_STR_LEN,
154151 "l7vs_conn="
@@ -164,8 +161,7 @@ inline void l7vs_conn_c_str(char* ret, const struct l7vs_conn* conn)
164161 "cldata_len=%zu: "
165162 "cldata_bufsize=%zu: "
166163 "cmss=%d: "
167- "sorry_conn_flag=%d: "
168- "old_dest=%s}"
164+ "sorry_conn_flag=%d}"
169165 , conn->lsock
170166 , conn->srv
171167 , dest_str
@@ -178,8 +174,7 @@ inline void l7vs_conn_c_str(char* ret, const struct l7vs_conn* conn)
178174 , conn->cldata_len
179175 , conn->cldata_bufsize
180176 , conn->cmss
181- , conn->sorry_conn_flag
182- , old_dest_str);
177+ , conn->sorry_conn_flag);
183178 }
184179
185180 #endif //L7VS_CONN_H
--- a/include/l7vs_sched.h
+++ b/include/l7vs_sched.h
@@ -55,6 +55,6 @@ extern void l7vs_sched_put( struct l7vs_scheduler* );
5555 extern void l7vs_sched_bind( struct l7vs_scheduler*, struct l7vs_service* );
5656 extern void l7vs_sched_unbind( struct l7vs_scheduler*, struct l7vs_service* );
5757 extern int l7vs_sched_sorry_check(struct l7vs_service*, int);
58-extern struct l7vs_dest* l7vs_sched_sorry_dest(struct l7vs_service*, struct l7vs_conn*, int);
58+extern struct l7vs_dest* l7vs_sched_sorry_dest(struct l7vs_service*, struct l7vs_conn*);
5959
6060 #endif //L7VS_SCHED_H
--- a/src/conn.c
+++ b/src/conn.c
@@ -403,7 +403,6 @@ l7vs_conn_create(int lfd, struct l7vs_lsock *lsock)
403403 }
404404 /*------ DEBUG LOG END ------*/
405405 conn->sorry_conn_flag = 0;
406- conn->old_dest = NULL;
407406 l7vs_iomux_add(conn->ciom, iom_read);
408407
409408 // connect real server immediately if all lsock services are fast schedule.
@@ -1060,135 +1059,42 @@ l7vs_conn_is_rs_connected(struct l7vs_iomux *iom, struct l7vs_conn *conn, struct
10601059 }
10611060 /*------ DEBUG LOG END ------*/
10621061
1063- //is real server connected?
10641062 if (-1 != conn->riom->fd) {
1065- // check sorry status of service
1066- // argment 0 means no connection count check
1063+ // Connection to real/sorry server is already ESTABLISHED
1064+
1065+ // Check force-sorry-flag and existance of real servers
10671066 sorry_state = l7vs_sched_sorry_check(conn->srv, 0);
10681067 if (sorry_state) {
1069- // check connect to sorry-server now
1068+ // force-sorry-flag is ON or no real servers
1069+
10701070 if (!conn->sorry_conn_flag) {
1071- // get sorry-server destination (argment 0)
1072- d = l7vs_sched_sorry_dest(conn->srv, conn, 0);
1071+ // Current connection is to real server,
1072+ // so close the connection.
10731073 /*-------- DEBUG LOG --------*/
10741074 if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_L7VSD_NETWORK)) {
1075- char sorry_dest_str1[DEBUG_STR_LEN] = {0};
1076- l7vs_dest_c_str(sorry_dest_str1, d);
1077- LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_NETWORK,116,
1078- "pointer_assign: d=%s",
1079- sorry_dest_str1);
1075+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_NETWORK,117,
1076+ "iom->status change: %d->%d",
1077+ iom->status, iomux_conn_disconnected);
10801078 }
10811079 /*------ DEBUG LOG END ------*/
1082- if (!d) {
1083- LOGGER_PUT_LOG_ERROR(LOG_CAT_L7VSD_NETWORK,18, "error / sorry-server dest NG");
1084- /*-------- DEBUG LOG --------*/
1085- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_L7VSD_NETWORK)) {
1086- LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_NETWORK,117,
1087- "iom->status change: %d->%d",
1088- iom->status, iomux_conn_rs_connect_error);
1089- }
1090- /*------ DEBUG LOG END ------*/
1091- iom->status = iomux_conn_rs_connect_error;
1092- /*-------- DEBUG LOG --------*/
1093- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_L7VSD_NETWORK)) {
1094- LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_NETWORK,118,
1095- "out_function: static int l7vs_conn_is_rs_connected("
1096- "struct l7vs_iomux *iom, struct l7vs_conn *conn, struct l7vs_service **srv, struct l7vs_dest **dest) "
1097- "return_value: 0");
1098- }
1099- /*------ DEBUG LOG END ------*/
1100- return 0;
1101- }
1102- conn->old_dest = conn->dest;
1080+ iom->status = iomux_conn_disconnected;
11031081 /*-------- DEBUG LOG --------*/
11041082 if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_L7VSD_NETWORK)) {
1105- char old_dest_str[DEBUG_STR_LEN] = {0};
1106- l7vs_dest_c_str(old_dest_str, conn->old_dest);
1107- LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_NETWORK,119,
1108- "pointer_assign: conn->old_dest=%s",
1109- old_dest_str);
1083+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_NETWORK,118,
1084+ "out_function: static int l7vs_conn_is_rs_connected("
1085+ "struct l7vs_iomux *iom, struct l7vs_conn *conn, struct l7vs_service **srv, struct l7vs_dest **dest) "
1086+ "return_value: 0");
11101087 }
11111088 /*------ DEBUG LOG END ------*/
1112- // change connection to sorry-server
1113- if (!l7vs_conn_change_connect_rs(conn, d)) {
1114- LOGGER_PUT_LOG_ERROR(LOG_CAT_L7VSD_NETWORK,19, "error / change connection to Sorry NG");
1115- /*-------- DEBUG LOG --------*/
1116- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_L7VSD_NETWORK)) {
1117- LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_NETWORK,120,
1118- "iom->status change: %d->%d",
1119- iom->status, iomux_conn_rs_connect_error);
1120- }
1121- /*------ DEBUG LOG END ------*/
1122- iom->status = iomux_conn_rs_connect_error;
1123- /*-------- DEBUG LOG --------*/
1124- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_L7VSD_NETWORK)) {
1125- LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_NETWORK,121,
1126- "out_function: static int l7vs_conn_is_rs_connected("
1127- "struct l7vs_iomux *iom, struct l7vs_conn *conn, struct l7vs_service **srv, struct l7vs_dest **dest) "
1128- "return_value: 0");
1129- }
1130- /*------ DEBUG LOG END ------*/
1131- return 0;
1132- }
1133- conn->sorry_conn_flag = 1;
1089+ return 0;
11341090 }
1135- } else {
1136- // check connect to sorry-server now
1137- if (conn->sorry_conn_flag) {
1138- // get old real-server destination (argment 1)
1139- d = l7vs_sched_sorry_dest(conn->srv, conn, 1);
1140- /*-------- DEBUG LOG --------*/
1141- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_L7VSD_NETWORK)) {
1142- char sorry_dest_str2[DEBUG_STR_LEN] = {0};
1143- l7vs_dest_c_str(sorry_dest_str2, d);
1144- LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_NETWORK,122,
1145- "pointer_assign: d=%s",
1146- sorry_dest_str2);
1147- }
1148- /*------ DEBUG LOG END ------*/
1149- if (!d) {
1150- LOGGER_PUT_LOG_ERROR(LOG_CAT_L7VSD_NETWORK,20, "error / old real-server dest NG");
1151- /*-------- DEBUG LOG --------*/
1152- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_L7VSD_NETWORK)) {
1153- LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_NETWORK,123,
1154- "iom->status change: %d->%d",
1155- iom->status, iomux_conn_rs_connect_error);
1156- }
1157- /*------ DEBUG LOG END ------*/
1158- iom->status = iomux_conn_rs_connect_error;
1159- /*-------- DEBUG LOG --------*/
1160- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_L7VSD_NETWORK)) {
1161- LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_NETWORK,124,
1162- "out_function: static int l7vs_conn_is_rs_connected("
1163- "struct l7vs_iomux *iom, struct l7vs_conn *conn, struct l7vs_service **srv, struct l7vs_dest **dest) "
1164- "return_value: 0");
1165- }
1166- /*------ DEBUG LOG END ------*/
1167- return 0;
1168- }
1169- // change connection to real-server
1170- if (!l7vs_conn_change_connect_rs(conn, d)) {
1171- LOGGER_PUT_LOG_ERROR(LOG_CAT_L7VSD_NETWORK,21, "error / change connection to RS NG");
1172- /*-------- DEBUG LOG --------*/
1173- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_L7VSD_NETWORK)) {
1174- LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_NETWORK,125,
1175- "iom->status change: %d->%d",
1176- iom->status, iomux_conn_rs_connect_error);
1177- }
1178- /*------ DEBUG LOG END ------*/
1179- iom->status = iomux_conn_rs_connect_error;
1180- /*-------- DEBUG LOG --------*/
1181- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_L7VSD_NETWORK)) {
1182- LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_NETWORK,126,
1183- "out_function: static int l7vs_conn_is_rs_connected("
1184- "struct l7vs_iomux *iom, struct l7vs_conn *conn, struct l7vs_service **srv, struct l7vs_dest **dest) "
1185- "return_value: 0");
1186- }
1187- /*------ DEBUG LOG END ------*/
1188- return 0;
1189- }
1190- conn->sorry_conn_flag = 0;
1091+ else {
1092+ // Current connection is already changed to sorry server,
1093+ // so do nothing.
11911094 }
1095+ } else {
1096+ // force-sorry-flag is OFF and real servers exist,
1097+ // then keep the connection to real/sorry server.
11921098 }
11931099 /*-------- DEBUG LOG --------*/
11941100 if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_L7VSD_NETWORK)) {
@@ -3507,17 +3413,6 @@ static int l7vs_conn_change_connect_rs(struct l7vs_conn *conn, struct l7vs_dest
35073413 /*------ DEBUG LOG END ------*/
35083414 return 0;
35093415 }
3510- // save old destination
3511- conn->old_dest = conn->dest;
3512- /*-------- DEBUG LOG --------*/
3513- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_L7VSD_NETWORK)) {
3514- char old_dest_str[DEBUG_STR_LEN] = {0};
3515- l7vs_dest_c_str(old_dest_str, conn->old_dest);
3516- LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_NETWORK,313,
3517- "pointer_assign: conn->old_dest=%s",
3518- old_dest_str);
3519- }
3520- /*------ DEBUG LOG END ------*/
35213416 // close real-server connection
35223417 l7vs_conn_close_rsock(conn);
35233418 // connect to new destination
--- a/src/lsock.c
+++ b/src/lsock.c
@@ -464,11 +464,9 @@ l7vs_lsock_select_service(struct l7vs_lsock *lsock,
464464 struct l7vs_dest *dest;
465465 int ret, val;
466466 struct l7vs_service *srv_tmp = NULL; //! temporary for srv
467- struct l7vs_dest *dest_tmp = NULL; //! temporary for dest
468467 size_t len_tmp = 0; //! temporary for len
469468 int sorry_save = 0; //! sorry dest save flag
470469 struct l7vs_service *srv_tmp2 = NULL; //! temporary for srv when select_dest NG
471- struct l7vs_dest *dest_tmp2 = NULL; //! temporary for dest when select_dest NG
472470 size_t len_tmp2 = 0; //! temporary for len when select_dest NG
473471 int sorry_save2 = 0; //! sorry dest save flag when select_dest NG
474472
@@ -492,11 +490,11 @@ l7vs_lsock_select_service(struct l7vs_lsock *lsock,
492490 if (ret == 0) {
493491 // check sorry status if ret == 0
494492 // sorry_check argument 1 means check connection count
493+ // Check the connection count(--upper, maxconn)
495494 if (l7vs_sched_sorry_check(srv, 1)) {
496495 if (!sorry_save) {
497496 // save sorry dest to xxx_tmp only first time
498497 srv_tmp = srv;
499- dest_tmp = dest;
500498 len_tmp = len;
501499 sorry_save = 1;
502500 }
@@ -517,10 +515,10 @@ l7vs_lsock_select_service(struct l7vs_lsock *lsock,
517515 }
518516 }
519517 // when select_dest NG
518+ // No suitable realservers exist
520519 if (!sorry_save2) {
521520 // save sorry dest to xxx_tmp2 only first time
522521 srv_tmp2 = srv;
523- dest_tmp2 = dest;
524522 len_tmp2 = len;
525523 sorry_save2 = 1;
526524 }
@@ -528,11 +526,11 @@ l7vs_lsock_select_service(struct l7vs_lsock *lsock,
528526 l = g_list_next(l);
529527 }
530528
529+ // Over maximum connections
531530 if (sorry_save) {
532531 // saved sorry dest is exist
533532 // set sorry-server destination
534- //*dest_ret = (struct l7vs_dest *)l7vs_sched_sorry_dest(srv_tmp, NULL, 1);
535- *dest_ret = (struct l7vs_dest *)l7vs_sched_sorry_dest(srv_tmp, NULL, 0);
533+ *dest_ret = (struct l7vs_dest *)l7vs_sched_sorry_dest(srv_tmp, NULL);
536534 if (!*dest_ret) {
537535 LOGGER_PUT_LOG_ERROR(LOG_CAT_L7VSD_SORRY_SERVER,2, "sorry-server dest is NULL");
538536 if (logger_get_log_level(LOG_CAT_L7VSD_REAL_SERVER) == LOG_LV_DEBUG) {
@@ -545,11 +543,12 @@ l7vs_lsock_select_service(struct l7vs_lsock *lsock,
545543 conn->cldata_len = len_tmp;
546544 conn->sorry_conn_flag = 1;
547545 val = 1;
546+
547+ // No suitable realservers exist
548548 } else if (sorry_save2) {
549549 // saved sorry dest2 is exist
550550 // set sorry-server destination
551- //*dest_ret = (struct l7vs_dest *)l7vs_sched_sorry_dest(srv_tmp2, NULL, 1);
552- *dest_ret = (struct l7vs_dest *)l7vs_sched_sorry_dest(srv_tmp2, NULL, 0);
551+ *dest_ret = (struct l7vs_dest *)l7vs_sched_sorry_dest(srv_tmp2, NULL);
553552 if (!*dest_ret) {
554553 LOGGER_PUT_LOG_ERROR(LOG_CAT_L7VSD_SORRY_SERVER,3, "sorry-server dest is NULL");
555554 if (logger_get_log_level(LOG_CAT_L7VSD_REAL_SERVER) == LOG_LV_DEBUG) {
--- a/src/sched.c
+++ b/src/sched.c
@@ -454,14 +454,13 @@ sorry_check_out:
454454 }
455455
456456 /*!
457- * Get sorry-server destination or old real-server destination.
457+ * Get sorry-server destination
458458 * @param[in] *srv service pointer
459459 * @param[in] *conn connection pointer
460- * @param[in] reverse specification which get sorry-server or old real-server
461460 * @return l7vs_dest* sorry-server or old real-server destination
462461 */
463462 struct l7vs_dest *
464-l7vs_sched_sorry_dest(struct l7vs_service *srv, struct l7vs_conn *conn, int reverse)
463+l7vs_sched_sorry_dest(struct l7vs_service *srv, struct l7vs_conn *conn)
465464 {
466465 struct l7vs_dest* dest = NULL;
467466
@@ -473,33 +472,18 @@ l7vs_sched_sorry_dest(struct l7vs_service *srv, struct l7vs_conn *conn, int reve
473472 l7vs_conn_c_str(conn_str, conn);
474473 LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_SCHEDULE,21,
475474 "in_function: struct l7vs_dest* l7vs_sched_sorry_dest(struct l7vs_service* srv, "
476- "struct l7vs_conn* conn, int reverse): srv=&(%s), conn=&(%s), reverse=%d",
477- srv_str, conn_str, reverse);
475+ "struct l7vs_conn* conn, int reverse): srv=&(%s), conn=&(%s)",
476+ srv_str, conn_str);
478477 }
479478 /*------ DEBUG LOG END ------*/
480479
481480 // argument check
482- if (reverse != 0 && reverse != 1) {
483- LOGGER_PUT_LOG_ERROR(LOG_CAT_L7VSD_SCHEDULE,13,"Invalid reverse value");
481+ if (!srv) {
482+ LOGGER_PUT_LOG_ERROR(LOG_CAT_L7VSD_SCHEDULE,14,"Argument srv is NULL pointer");
484483 goto sorry_dest_out;
485484 }
486- if (!reverse) {
487- // argument check
488- if (!srv) {
489- LOGGER_PUT_LOG_ERROR(LOG_CAT_L7VSD_SCHEDULE,14,"Argument srv is NULL pointer");
490- goto sorry_dest_out;
491- }
492- // return sorry-server destination
493- dest = srv->sorry_dest;
494- } else {
495- // argument check
496- if (!conn) {
497- LOGGER_PUT_LOG_ERROR(LOG_CAT_L7VSD_SCHEDULE,15,"Argument srv is NULL pointer");
498- goto sorry_dest_out;
499- }
500- // return old real-server destination
501- dest = conn->old_dest;
502- }
485+ // return sorry-server destination
486+ dest = srv->sorry_dest;
503487
504488 sorry_dest_out:
505489
@@ -515,7 +499,7 @@ sorry_dest_out:
515499 l7vs_dest_c_str(dest_str, dest);
516500 LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_SCHEDULE,22,
517501 "out_function: struct l7vs_dest* l7vs_sched_sorry_dest(struct l7vs_service* srv, "
518- "struct l7vs_conn* conn, int reverse): return_value=&(%s)", dest_str);
502+ "struct l7vs_conn* conn): return_value=&(%s)", dest_str);
519503 }
520504 /*------ DEBUG LOG END ------*/
521505
旧リポジトリブラウザで表示