リビジョン | 7d88ae09dcf9a4a4d3a2dafb18be784e246c6959 (tree) |
---|---|
日時 | 2014-07-31 16:34:48 |
作者 | Hiroaki Nakano <nakano.hiroaki@nttc...> |
コミッター | Hiroaki Nakano |
edit途中。
やっと親プロセスや子プロセスが死ななくなった。
- perrorをsys_errlist[errno]に変更
- 子プロセスで親プロセス用のnamed pipeを閉じるようにした。
- 子プロセスでUNIXソケットを閉じるIFを用意(現在は無効にしてる)
Signed-off-by: Hiroaki Nakano <nakano.hiroaki@nttcom.co.jp>
@@ -269,4 +269,16 @@ extern int l7vs_config_init(); | ||
269 | 269 | */ |
270 | 270 | extern void l7vs_config_fini(); |
271 | 271 | |
272 | +/*! | |
273 | + * l7vs_config_close() | |
274 | + * configuration socket close function. | |
275 | + */ | |
276 | +extern void l7vs_config_close(); | |
277 | + | |
278 | +/*! | |
279 | + * l7vs_pfifo_close() | |
280 | + * parent fifo close function. | |
281 | + */ | |
282 | +extern void l7vs_pfifo_close(); | |
283 | + | |
272 | 284 | #endif //L7VS_CONFIG_H |
@@ -138,6 +138,14 @@ enum iomstatus{ | ||
138 | 138 | //pid_notify |
139 | 139 | iomux_pfifo_read_waiting, //! notified combination of pid and ip+port for parent process from child |
140 | 140 | |
141 | + // pfifo common | |
142 | +// iomux_pfifo_init, //! pfifo before initialize | |
143 | +// iomux_pfifo_initialized, //! pfifo was initialized | |
144 | +// iomux_pfifo_command_waiting, //! command waiting | |
145 | +// iomux_pfifo_command_response_sent, //! command response sent | |
146 | +// iomux_pfifo_signal_received, //! signal received | |
147 | + iomux_pfifo_destroyed, //! pfifo finishing process was executed | |
148 | + | |
141 | 149 | //lsock_initialize |
142 | 150 | iomux_lsock_init, //! listening socket before initialize |
143 | 151 | iomux_lsock_initalized, //! listening socket was initialized |
@@ -207,7 +207,7 @@ l7vs_config_init(void) | ||
207 | 207 | // exist same name file. |
208 | 208 | if(logger_get_log_level(LOG_CAT_L7VSD_SYSTEM) == LOG_LV_DEBUG){ |
209 | 209 | LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_SYSTEM,1, |
210 | - "config_init: stat error 1 return -1"); | |
210 | + "config_init: stat error: %s", sys_errlist[errno]); | |
211 | 211 | } |
212 | 212 | unlink(addr.sun_path); |
213 | 213 | return -1; |
@@ -218,10 +218,10 @@ l7vs_config_init(void) | ||
218 | 218 | S_IRUSR | S_IWUSR | S_IXUSR | |
219 | 219 | S_IRGRP | S_IXGRP | |
220 | 220 | S_IROTH | S_IXOTH); |
221 | - if(ret == -1){ | |
221 | + if(ret == -1 && errno != EEXIST){ | |
222 | 222 | if(logger_get_log_level(LOG_CAT_L7VSD_SYSTEM) == LOG_LV_DEBUG){ |
223 | 223 | LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_SYSTEM,1, |
224 | - "config_init: mkdir error 1 return -1"); | |
224 | + "config_init: mkdir error: %s", sys_errlist[errno]); | |
225 | 225 | } |
226 | 226 | unlink(addr.sun_path); |
227 | 227 | return -1; |
@@ -229,7 +229,7 @@ l7vs_config_init(void) | ||
229 | 229 | }else{ |
230 | 230 | if(logger_get_log_level(LOG_CAT_L7VSD_SYSTEM) == LOG_LV_DEBUG){ |
231 | 231 | LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_SYSTEM,1, |
232 | - "config_init: stat error 2 return -1"); | |
232 | + "config_init: stat error 2: %s", sys_errlist[errno]); | |
233 | 233 | } |
234 | 234 | unlink(addr.sun_path); |
235 | 235 | return -1; |
@@ -245,7 +245,7 @@ l7vs_config_init(void) | ||
245 | 245 | if(ret < 0 && errno != EEXIST){ |
246 | 246 | if(logger_get_log_level(LOG_CAT_L7VSD_SYSTEM) == LOG_LV_DEBUG){ |
247 | 247 | LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_SYSTEM,1, |
248 | - "out_fuction: mkfifo error 1 return -1"); | |
248 | + "out_fuction: mkfifo error 1: %s", sys_errlist[errno]); | |
249 | 249 | } |
250 | 250 | unlink(addr.sun_path); |
251 | 251 | return -1; |
@@ -291,6 +291,59 @@ l7vs_config_init(void) | ||
291 | 291 | } |
292 | 292 | |
293 | 293 | /*! |
294 | + * Operate config parent fifo fd close | |
295 | + * @return void | |
296 | + */ | |
297 | +void | |
298 | +l7vs_pfifo_close(void) | |
299 | +{ | |
300 | + if(logger_get_log_level(LOG_CAT_L7VSD_ENVIRONMENT) == LOG_LV_DEBUG){ | |
301 | + LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_ENVIRONMENT,3, | |
302 | + "in_fuction: void l7vs_pfifo_close return void"); | |
303 | + } | |
304 | + if (l7vs_pfifo_iomux) { | |
305 | + l7vs_pfifo_iomux->status = iomux_pfifo_destroyed; | |
306 | + l7vs_iomux_remove(l7vs_pfifo_iomux); | |
307 | + if (-1 != l7vs_pfifo_iomux->fd) { | |
308 | + close(l7vs_pfifo_iomux->fd); | |
309 | + } | |
310 | + l7vs_iomux_put_to_avail_list(l7vs_pfifo_iomux); | |
311 | + l7vs_pfifo_iomux = NULL; | |
312 | + } | |
313 | + if(logger_get_log_level(LOG_CAT_L7VSD_ENVIRONMENT) == LOG_LV_DEBUG){ | |
314 | + LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_ENVIRONMENT,4, | |
315 | + "out_fuction: void l7vs_pfifo_close return void"); | |
316 | + } | |
317 | + | |
318 | +} | |
319 | + | |
320 | +/*! | |
321 | + * Operate config fd close | |
322 | + * @return void | |
323 | + */ | |
324 | +void | |
325 | +l7vs_config_close(void) | |
326 | +{ | |
327 | + if(logger_get_log_level(LOG_CAT_L7VSD_ENVIRONMENT) == LOG_LV_DEBUG){ | |
328 | + LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_ENVIRONMENT,3, | |
329 | + "in_fuction: void l7vs_config_close return void"); | |
330 | + } | |
331 | + if (l7vs_config_iomux) { | |
332 | + l7vs_config_iomux->status = iomux_config_destroyed; | |
333 | + l7vs_iomux_remove(l7vs_config_iomux); | |
334 | + if (-1 != l7vs_config_iomux->fd) { | |
335 | + close(l7vs_config_iomux->fd); | |
336 | + } | |
337 | + l7vs_iomux_put_to_avail_list(l7vs_config_iomux); | |
338 | + l7vs_config_iomux = NULL; | |
339 | + } | |
340 | + if(logger_get_log_level(LOG_CAT_L7VSD_ENVIRONMENT) == LOG_LV_DEBUG){ | |
341 | + LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_ENVIRONMENT,4, | |
342 | + "out_fuction: void l7vs_config_close return void"); | |
343 | + } | |
344 | +} | |
345 | + | |
346 | +/*! | |
294 | 347 | * Operate config finish |
295 | 348 | * @return void |
296 | 349 | */ |
@@ -429,7 +482,7 @@ l7vs_config_callback(struct l7vs_iomux *iom ) | ||
429 | 482 | * pfifo call back |
430 | 483 | * @param[in] struct l7vs_iomux l7vs_iomux pointer |
431 | 484 | * @return int OK=0, NG<0 |
432 | - */ | |
485 | + */ | |
433 | 486 | static int |
434 | 487 | l7vs_pfifo_callback(struct l7vs_iomux *iom ) |
435 | 488 | { |
@@ -70,6 +70,7 @@ static l7vs_service_repdata * rep_mirror; | ||
70 | 70 | |
71 | 71 | //static functions |
72 | 72 | static void l7vs_service_put_service_arg(struct l7vs_service_arg_multi *); |
73 | +//static int l7vs_pfifo_callback(struct l7vs_iomux *); | |
73 | 74 | |
74 | 75 | // throughput interval |
75 | 76 | static int throughput_interval = 0; |
@@ -80,6 +81,9 @@ static char childinfo[64]; | ||
80 | 81 | // child process fifo event |
81 | 82 | static struct l7vs_iomux *l7vs_cfifo_iomux; |
82 | 83 | |
84 | +// parent process fifo event | |
85 | +//static struct l7vs_iomux *l7vs_pfifo_iomux; | |
86 | + | |
83 | 87 | /*! |
84 | 88 | * make replication data from l7vs_service structure |
85 | 89 | * @param[in] num unsigned int/number of array(l7vs_service_repdata) |
@@ -1101,6 +1105,150 @@ l7vs_cfifo_callback(struct l7vs_iomux *iom ) | ||
1101 | 1105 | } |
1102 | 1106 | |
1103 | 1107 | /*! |
1108 | + * create parent named pipe | |
1109 | + */ | |
1110 | +/* | |
1111 | +int | |
1112 | +create_parent_named_pipe(void) | |
1113 | +{ | |
1114 | + int ret, fd; | |
1115 | + struct stat st; | |
1116 | + | |
1117 | + // directory check | |
1118 | + ret = stat(P_FIFO_PATH, &st); | |
1119 | + if(!ret){ | |
1120 | + if(!(S_ISDIR(st.st_mode))){ | |
1121 | + // exist same name file. | |
1122 | + if(logger_get_log_level(LOG_CAT_L7VSD_SYSTEM) == LOG_LV_DEBUG){ | |
1123 | + LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_SYSTEM,1, | |
1124 | + "config_init: stat error: %s", sys_errlist[errno]); | |
1125 | + } | |
1126 | + return -1; | |
1127 | + } | |
1128 | + }else{ | |
1129 | + if(errno == ENOENT){ | |
1130 | + ret = mkdir(P_FIFO_PATH, | |
1131 | + S_IRUSR | S_IWUSR | S_IXUSR | | |
1132 | + S_IRGRP | S_IXGRP | | |
1133 | + S_IROTH | S_IXOTH); | |
1134 | + if(ret == -1 && errno != EEXIST){ | |
1135 | + if(logger_get_log_level(LOG_CAT_L7VSD_SYSTEM) == LOG_LV_DEBUG){ | |
1136 | + LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_SYSTEM,1, | |
1137 | + "config_init: mkdir error: %s", sys_errlist[errno]); | |
1138 | + } | |
1139 | + return -1; | |
1140 | + } | |
1141 | + }else{ | |
1142 | + if(logger_get_log_level(LOG_CAT_L7VSD_SYSTEM) == LOG_LV_DEBUG){ | |
1143 | + LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_SYSTEM,1, | |
1144 | + "config_init: stat error 2: %s", sys_errlist[errno]); | |
1145 | + } | |
1146 | + return -1; | |
1147 | + } | |
1148 | + } | |
1149 | + if(logger_get_log_level(LOG_CAT_L7VSD_SYSTEM_SOCKET) == LOG_LV_DEBUG){ | |
1150 | + LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_SYSTEM_SOCKET,1, | |
1151 | + "directory_check: named pipe directory is ok."); | |
1152 | + } | |
1153 | + | |
1154 | + // create parent named pipe | |
1155 | + ret = mkfifo(P_FIFO, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); | |
1156 | + if(ret < 0 && errno != EEXIST){ | |
1157 | + if(logger_get_log_level(LOG_CAT_L7VSD_SYSTEM) == LOG_LV_DEBUG){ | |
1158 | + LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_SYSTEM,1, | |
1159 | + "out_fuction: mkfifo error 1: %s", sys_errlist[errno]); | |
1160 | + } | |
1161 | + return -1; | |
1162 | + } | |
1163 | + if(logger_get_log_level(LOG_CAT_L7VSD_SYSTEM_SOCKET) == LOG_LV_DEBUG){ | |
1164 | + LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_SYSTEM_SOCKET,1, | |
1165 | + "mkfifo: named pipe create."); | |
1166 | + } | |
1167 | + | |
1168 | + // open fifo | |
1169 | + | |
1170 | + fd = open(P_FIFO, O_RDONLY|O_NONBLOCK); | |
1171 | + if(logger_get_log_level(LOG_CAT_L7VSD_SYSTEM_SOCKET) == LOG_LV_DEBUG){ | |
1172 | + LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_SYSTEM_SOCKET,1, | |
1173 | + "open: named pipe open. fd = %d",fd); | |
1174 | + } | |
1175 | + if(fd < 0) { | |
1176 | + if(logger_get_log_level(LOG_CAT_L7VSD_SYSTEM) == LOG_LV_DEBUG){ | |
1177 | + LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_SYSTEM,1, | |
1178 | + "out_fuction: open error: %s" | |
1179 | + ,sys_errlist[errno]); | |
1180 | + } | |
1181 | + return -1; | |
1182 | + } | |
1183 | + | |
1184 | + // set iomux for parent named pipe | |
1185 | + l7vs_pfifo_iomux = l7vs_iomux_get_from_avail_list(); | |
1186 | + l7vs_pfifo_iomux->fd = fd; | |
1187 | + l7vs_pfifo_iomux->data = NULL; | |
1188 | + l7vs_pfifo_iomux->callback = l7vs_pfifo_callback; | |
1189 | + l7vs_pfifo_iomux->status = iomux_pfifo_read_waiting; | |
1190 | + l7vs_iomux_add( l7vs_pfifo_iomux, iom_read ); | |
1191 | + | |
1192 | + if(logger_get_log_level(LOG_CAT_L7VSD_SYSTEM_SOCKET) == LOG_LV_DEBUG){ | |
1193 | + char iomux_str[DEBUG_STR_LEN] = {0}; | |
1194 | + l7vs_iomux_c_str(iomux_str,l7vs_pfifo_iomux); | |
1195 | + LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_PROGRAM,24, | |
1196 | + "creat: l7vs_config_iomux=%s", | |
1197 | + iomux_str); | |
1198 | + } | |
1199 | + | |
1200 | + return 0; | |
1201 | +} | |
1202 | +*/ | |
1203 | +/*! | |
1204 | + * pfifo call back | |
1205 | + * @param[in] struct l7vs_iomux l7vs_iomux pointer | |
1206 | + * @return int OK=0, NG<0 | |
1207 | + */ | |
1208 | +/* | |
1209 | +static int | |
1210 | +l7vs_pfifo_callback(struct l7vs_iomux *iom ) | |
1211 | +{ | |
1212 | + int ret; | |
1213 | + | |
1214 | + if (!iom) { | |
1215 | + LOGGER_PUT_LOG_ERROR(LOG_CAT_L7VSD_ENVIRONMENT,2,"error / iom is null"); | |
1216 | + if(logger_get_log_level(LOG_CAT_L7VSD_ENVIRONMENT) == LOG_LV_DEBUG){ | |
1217 | + LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_ENVIRONMENT,5, | |
1218 | + "out_fuction: int l7vs_pfifo_callback (struct l7vs_iomux *iom) return -1"); | |
1219 | + } | |
1220 | + return -1; | |
1221 | + } | |
1222 | + if (iomux_pfifo_read_waiting != iom->status) { | |
1223 | + LOGGER_PUT_LOG_ERROR(LOG_CAT_L7VSD_EVENT,2,"error / invalid status(%d)", iom->status); | |
1224 | + if(logger_get_log_level(LOG_CAT_L7VSD_ENVIRONMENT) == LOG_LV_DEBUG){ | |
1225 | + LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_ENVIRONMENT,6, | |
1226 | + "out_fuction: int l7vs_pfifo_callback (struct l7vs_iomux *iom) return -1"); | |
1227 | + } | |
1228 | + return -1; | |
1229 | + } | |
1230 | + | |
1231 | + if(logger_get_log_level(LOG_CAT_L7VSD_ENVIRONMENT) == LOG_LV_DEBUG){ | |
1232 | + LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_ENVIRONMENT,7, | |
1233 | + "in_fuction: int l7vs_pfifo_callback (struct l7vs_iomux *iom) iom = %p",iom); | |
1234 | + } | |
1235 | + | |
1236 | + | |
1237 | + ret = l7vs_receive_child_process_info(iom->fd); | |
1238 | + if(ret==-1){ | |
1239 | + return -1; | |
1240 | + } | |
1241 | + | |
1242 | + l7vs_pfifo_iomux->status = iomux_pfifo_read_waiting; | |
1243 | + if(logger_get_log_level(LOG_CAT_L7VSD_NETWORK) == LOG_LV_DEBUG){ | |
1244 | + LOGGER_PUT_LOG_DEBUG(LOG_CAT_L7VSD_NETWORK,9, | |
1245 | + "out_fuction: int l7vs_pfifo_callback (struct l7vs_iomux *iom) return 0"); | |
1246 | + } | |
1247 | + | |
1248 | + return 0; | |
1249 | +} | |
1250 | +*/ | |
1251 | +/*! | |
1104 | 1252 | * create service instance. and set service value. |
1105 | 1253 | * @param[in] *arg l7vs_service_arg pointer |
1106 | 1254 | * @param[out] *err error code |
@@ -1169,11 +1317,17 @@ l7vs_service_create(struct l7vs_service_arg_multi *arg, int *err) | ||
1169 | 1317 | |
1170 | 1318 | /* IPとportが重複しない場合は子プロセスを作る */ |
1171 | 1319 | if( srv_sock_check_flg == 0 ) { |
1172 | - fork_num = sysconf(_SC_NPROCESSORS_ONLN); | |
1320 | + fork_num = sysconf(_SC_NPROCESSORS_ONLN); | |
1173 | 1321 | for( i=0; i < fork_num; i++ ){ |
1174 | 1322 | pid_t pid = fork(); |
1175 | 1323 | /* 子プロセスを生成したら親プロセスでIP,portとPIDの対応リストを作る */ |
1176 | 1324 | |
1325 | + /* 親プロセスから引き継いだUNIXドメインソケットを閉じる */ | |
1326 | + //l7vs_config_close(); | |
1327 | + | |
1328 | + /* 親プロセス用PIPEを閉じる */ | |
1329 | + l7vs_pfifo_close(); | |
1330 | + | |
1177 | 1331 | /* 子ならgetpidして親に名前付きパイプで通知 */ |
1178 | 1332 | if( pid == 0 ){ |
1179 | 1333 | /* ソケット作成 */ |
@@ -1189,38 +1343,58 @@ l7vs_service_create(struct l7vs_service_arg_multi *arg, int *err) | ||
1189 | 1343 | snprintf(fifopath, sizeof(fifopath), "/tmp/l7vsd_%s_%d", ip, port); |
1190 | 1344 | ret = stat(fifopath, &st); |
1191 | 1345 | if(!ret){ |
1192 | - if(!(S_ISDIR(st.st_mode))){ | |
1193 | - // exist same name file. | |
1194 | - perror("stat"); | |
1195 | - return NULL; | |
1196 | - } | |
1346 | + if(!(S_ISDIR(st.st_mode))){ | |
1347 | + // exist same name file. | |
1348 | + //DEBUG output | |
1349 | + if( LOG_LV_DEBUG == logger_get_log_level( LOG_CAT_L7VSD_VIRTUAL_SERVICE ) ){ | |
1350 | + LOGGER_PUT_LOG_DEBUG( LOG_CAT_L7VSD_VIRTUAL_SERVICE,31, | |
1351 | + "l7vs_service_create: stat error: %s", sys_errlist[errno] ); | |
1352 | + } | |
1353 | + return NULL; | |
1354 | + } | |
1197 | 1355 | }else{ |
1198 | - if(errno == ENOENT){ | |
1199 | - ret = mkdir(fifopath, | |
1200 | - S_IRUSR | S_IWUSR | S_IXUSR | S_ISVTX | | |
1201 | - S_IRGRP | S_IXGRP | | |
1202 | - S_IROTH | S_IXOTH); | |
1203 | - if(ret == -1){ | |
1204 | - perror("mkdir"); | |
1205 | - return NULL; | |
1206 | - } | |
1207 | - }else{ | |
1208 | - perror("stat"); | |
1209 | - return NULL; | |
1210 | - } | |
1356 | + if(errno == ENOENT){ | |
1357 | + ret = mkdir(fifopath, | |
1358 | + S_IRUSR | S_IWUSR | S_IXUSR | S_ISVTX | | |
1359 | + S_IRGRP | S_IXGRP | | |
1360 | + S_IROTH | S_IXOTH); | |
1361 | + if(ret == -1 && errno != EEXIST){ | |
1362 | + //DEBUG output | |
1363 | + if( LOG_LV_DEBUG == logger_get_log_level( LOG_CAT_L7VSD_VIRTUAL_SERVICE ) ){ | |
1364 | + LOGGER_PUT_LOG_DEBUG( LOG_CAT_L7VSD_VIRTUAL_SERVICE,32, | |
1365 | + "l7vs_service_create: mkdir error: %s", sys_errlist[errno] ); | |
1366 | + } | |
1367 | + return NULL; | |
1368 | + } | |
1369 | + }else{ | |
1370 | + //DEBUG output | |
1371 | + if( LOG_LV_DEBUG == logger_get_log_level( LOG_CAT_L7VSD_VIRTUAL_SERVICE ) ){ | |
1372 | + LOGGER_PUT_LOG_DEBUG( LOG_CAT_L7VSD_VIRTUAL_SERVICE,33, | |
1373 | + "l7vs_service_create: stat error: %s", sys_errlist[errno] ); | |
1374 | + } | |
1375 | + return NULL; | |
1376 | + } | |
1211 | 1377 | } |
1212 | 1378 | |
1213 | 1379 | snprintf(fifoname, sizeof(fifoname), "/tmp/l7vsd_%s_%d/l7vsd.%d", ip, port, pid); |
1214 | 1380 | ret = mkfifo(fifoname, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); |
1215 | 1381 | if(ret == -1){ |
1216 | - perror("mkfifo"); | |
1382 | + //DEBUG output | |
1383 | + if( LOG_LV_DEBUG == logger_get_log_level( LOG_CAT_L7VSD_VIRTUAL_SERVICE ) ){ | |
1384 | + LOGGER_PUT_LOG_DEBUG( LOG_CAT_L7VSD_VIRTUAL_SERVICE,34, | |
1385 | + "l7vs_service_create: mkfifo error: %s", sys_errlist[errno] ); | |
1386 | + } | |
1217 | 1387 | /* 各種アンロード */ |
1218 | 1388 | return NULL; |
1219 | 1389 | } |
1220 | 1390 | |
1221 | 1391 | /* open fifo */ |
1222 | 1392 | if((readfifo = open(fifoname, O_RDONLY|O_NONBLOCK)) < 0) { |
1223 | - perror("open"); | |
1393 | + //DEBUG output | |
1394 | + if( LOG_LV_DEBUG == logger_get_log_level( LOG_CAT_L7VSD_VIRTUAL_SERVICE ) ){ | |
1395 | + LOGGER_PUT_LOG_DEBUG( LOG_CAT_L7VSD_VIRTUAL_SERVICE,35, | |
1396 | + "l7vs_service_create: child pipe open error: %s", sys_errlist[errno] ); | |
1397 | + } | |
1224 | 1398 | return NULL; |
1225 | 1399 | } |
1226 | 1400 |
@@ -1233,16 +1407,26 @@ l7vs_service_create(struct l7vs_service_arg_multi *arg, int *err) | ||
1233 | 1407 | l7vs_iomux_add( l7vs_cfifo_iomux, iom_read ); |
1234 | 1408 | |
1235 | 1409 | /* 親PIPEを開いてPIDとIP,portを親に通知 */ |
1410 | + /* リトライするかどうか・・・sleepいれる? */ | |
1236 | 1411 | snprintf(childinfo, sizeof(childinfo), "%s %d %d", ip, port, pid); |
1412 | + //sleep(2); | |
1237 | 1413 | if((writefifo = open(P_FIFO, O_WRONLY, 0)) < 0) { |
1238 | - perror("open"); | |
1414 | + //DEBUG output | |
1415 | + if( LOG_LV_DEBUG == logger_get_log_level( LOG_CAT_L7VSD_VIRTUAL_SERVICE ) ){ | |
1416 | + LOGGER_PUT_LOG_DEBUG( LOG_CAT_L7VSD_VIRTUAL_SERVICE,36, | |
1417 | + "l7vs_service_create: parent pipe open error: %s", sys_errlist[errno] ); | |
1418 | + } | |
1239 | 1419 | /* 各種アンロード */ |
1240 | 1420 | continue; |
1241 | 1421 | }else{ |
1242 | 1422 | /* 名前付きパイプに情報を書き込み */ |
1243 | 1423 | ret = write(writefifo, childinfo, sizeof(childinfo)); |
1244 | 1424 | if(ret < 0){ |
1245 | - perror("write"); | |
1425 | + //DEBUG output | |
1426 | + if( LOG_LV_DEBUG == logger_get_log_level( LOG_CAT_L7VSD_VIRTUAL_SERVICE ) ){ | |
1427 | + LOGGER_PUT_LOG_DEBUG( LOG_CAT_L7VSD_VIRTUAL_SERVICE,37, | |
1428 | + "l7vs_service_create: write error: %s", sys_errlist[errno] ); | |
1429 | + } | |
1246 | 1430 | /* 各種アンロード */ |
1247 | 1431 | } |
1248 | 1432 | close(writefifo); |
@@ -1262,14 +1446,18 @@ l7vs_service_create(struct l7vs_service_arg_multi *arg, int *err) | ||
1262 | 1446 | }else if( pid > 0 ){ |
1263 | 1447 | /* 親プロセス処理 */ |
1264 | 1448 | |
1265 | - /* l7vs_child_proto_grpを初期化作成してリスト登録 */ | |
1449 | + /* l7vs_child_proto_grpを初期化作成してリスト登録←複数回を考慮 */ | |
1266 | 1450 | grp = l7vs_child_proto_grp_init(arg->srv_arg.addr.sin_addr.s_addr, |
1267 | 1451 | arg->srv_arg.addr.sin_port, |
1268 | 1452 | arg->srv_arg.protomod ); |
1269 | 1453 | |
1270 | 1454 | }else if( pid < 0 ){ |
1271 | 1455 | /* 子プロセス作成失敗 */ |
1272 | - perror( "fork" ); | |
1456 | + //DEBUG output | |
1457 | + if( LOG_LV_DEBUG == logger_get_log_level( LOG_CAT_L7VSD_VIRTUAL_SERVICE ) ){ | |
1458 | + LOGGER_PUT_LOG_DEBUG( LOG_CAT_L7VSD_VIRTUAL_SERVICE,38, | |
1459 | + "l7vs_service_create: fork error: %s", sys_errlist[errno] ); | |
1460 | + } | |
1273 | 1461 | return NULL; |
1274 | 1462 | } |
1275 | 1463 | } |
@@ -1292,9 +1480,21 @@ l7vs_receive_child_process_info(int fd) | ||
1292 | 1480 | struct l7vs_child_proto_grp *grp; |
1293 | 1481 | int ret; |
1294 | 1482 | |
1483 | + //DEBUG output | |
1484 | + if( LOG_LV_DEBUG == logger_get_log_level( LOG_CAT_L7VSD_VIRTUAL_SERVICE ) ){ | |
1485 | + char debugstr[DEBUG_STR_LEN]; | |
1486 | + memset( debugstr, 0, DEBUG_STR_LEN ); | |
1487 | + sprintf( debugstr, "function l7vs_receive_child_process_info(int fd)" ); | |
1488 | + LOGGER_PUT_LOG_DEBUG( LOG_CAT_L7VSD_VIRTUAL_SERVICE,43, debugstr ); | |
1489 | + } | |
1490 | + | |
1295 | 1491 | // 読み込み |
1296 | 1492 | if((read(fd, childinfo, sizeof(childinfo)))==-1) { |
1297 | - perror("read"); | |
1493 | + //DEBUG output | |
1494 | + if( LOG_LV_DEBUG == logger_get_log_level( LOG_CAT_L7VSD_VIRTUAL_SERVICE ) ){ | |
1495 | + LOGGER_PUT_LOG_DEBUG( LOG_CAT_L7VSD_VIRTUAL_SERVICE,39, | |
1496 | + "l7vs_receive_child_process_info: read error: %s", sys_errlist[errno] ); | |
1497 | + } | |
1298 | 1498 | return -1; |
1299 | 1499 | } |
1300 | 1500 |
@@ -1302,13 +1502,23 @@ l7vs_receive_child_process_info(int fd) | ||
1302 | 1502 | sscanf(childinfo, "%s %d %d", ip, port, pid); |
1303 | 1503 | // 取り出した情報をネットワークバイトオーダーに変換する |
1304 | 1504 | if(!(inet_aton(ip, &nip))){ |
1305 | - return -1; | |
1505 | + //DEBUG output | |
1506 | + if( LOG_LV_DEBUG == logger_get_log_level( LOG_CAT_L7VSD_VIRTUAL_SERVICE ) ){ | |
1507 | + LOGGER_PUT_LOG_DEBUG( LOG_CAT_L7VSD_VIRTUAL_SERVICE,41, | |
1508 | + "l7vs_receive_child_process_info: inet_aton error: %s", sys_errlist[errno] ); | |
1509 | + } | |
1510 | + return -1; | |
1306 | 1511 | } |
1307 | 1512 | nport = htons(port); |
1308 | 1513 | |
1309 | 1514 | // ipとportからl7vs_child_proto_grpを検索 |
1310 | 1515 | grp = l7vs_child_proto_grp_search(nip, nport); |
1311 | 1516 | if(grp == NULL) { |
1517 | + //DEBUG output | |
1518 | + if( LOG_LV_DEBUG == logger_get_log_level( LOG_CAT_L7VSD_VIRTUAL_SERVICE ) ){ | |
1519 | + LOGGER_PUT_LOG_DEBUG( LOG_CAT_L7VSD_VIRTUAL_SERVICE,42, | |
1520 | + "l7vs_receive_child_process_info: l7vs_child_proto_grp_search error." ); | |
1521 | + } | |
1312 | 1522 | return -1; |
1313 | 1523 | } |
1314 | 1524 | // pidを追加 |