| 304 | |
| 305 | |
| 306 | void |
| 307 | client_loop(const struct bench_options *options, int stc[2], int cts[2]) |
| 308 | { |
| 309 | EState *estate; |
| 310 | struct itimerval timeout_val; |
| 311 | bool has_error = false; |
| 312 | TupleChunkListData *tc_list_raw_buffer; |
| 313 | struct directTransportBuffer direct_buffer; |
| 314 | int8 already_stop = 0; |
| 315 | |
| 316 | uint64 direct_hit = 0; |
| 317 | uint64 non_direct_hit = 0; |
| 318 | |
| 319 | init_memory_context(); |
| 320 | estate = client_side_setup(options, stc, cts); |
| 321 | if (!estate) |
| 322 | { |
| 323 | /* can not use signal to notify server side now */ |
| 324 | printf("client side setup failed.\n"); |
| 325 | return; |
| 326 | } |
| 327 | |
| 328 | signal(SIGALRM, sig_handler); |
| 329 | signal(SIGUSR1, sig_handler); |
| 330 | |
| 331 | tc_list_raw_buffer = build_chunk_tuple_slot(estate, options->bsize); |
| 332 | |
| 333 | timeout_val.it_value.tv_sec = options->interval; |
| 334 | timeout_val.it_value.tv_usec = 0; |
| 335 | timeout_val.it_interval.tv_sec = 0; |
| 336 | timeout_val.it_interval.tv_usec = 0; |
| 337 | setitimer(ITIMER_REAL, &timeout_val, NULL); |
| 338 | |
| 339 | while (true) |
| 340 | { |
| 341 | if (interrupt_flag) |
| 342 | { |
| 343 | kill(server_side_pid, SIGALRM); |
| 344 | int n = 0; |
| 345 | |
| 346 | if (fcntl(stc[0], F_SETFL, fcntl(stc[0], F_GETFL) | O_NONBLOCK) != 0) |
| 347 | { |
| 348 | printf("client side exit failed.\n"); |
| 349 | return; |
| 350 | } |
| 351 | |
| 352 | /* waiting for server side stuck in recv or break. */ |
| 353 | sleep(0.1); |
| 354 | while ((n = read(stc[0], &already_stop, sizeof(int8))) < 0) |
| 355 | { |
| 356 | if (errno == EAGAIN || errno == EWOULDBLOCK) |
| 357 | { |
| 358 | CurrentMotionIPCLayer->SendTupleChunkToAMS(estate->interconnect_context, 1, 0, tc_list_raw_buffer->p_first); |
| 359 | continue; |
| 360 | } |
| 361 | else |
| 362 | { |
| 363 | printf("client side read signal failed failed.\n"); |
no test coverage detected