• R/O
  • SSH

fcfserver: Commit

Server application performing load balancing and monitoring of nodejs applications


Commit MetaInfo

Revision7a57894ec7b0fe2338791334d7292ed7ce0634f9 (tree)
Zeit2021-05-07 15:26:23
AutorVladimir Markin <v.o.markin221@gmai...>
CommiterVladimir Markin

Log Message

fix VERSION 1.1.2

Ändern Zusammenfassung

Diff

diff -r 3e701961df79 -r 7a57894ec7b0 endpoint.cpp
--- a/endpoint.cpp Fri May 07 08:18:35 2021 +0300
+++ b/endpoint.cpp Fri May 07 09:26:23 2021 +0300
@@ -426,24 +426,20 @@
426426 if (!is_big_data) {
427427 if (first_buffer_offset < full_pack)
428428 residual_buffer.resize(full_pack - first_buffer_offset);
429- bool firstEmpty = true;
430429 while (rec_total_size < full_pack) {
431430 size_t size = a_socket->recv(&residual_buffer[rec_total_size - first_buffer_offset], full_pack - rec_total_size < MAX_PACK ? full_pack - rec_total_size : MAX_PACK);
432- if (!size && !firstEmpty)
433- throw std::runtime_error("Empty receive data (recv())");
434- firstEmpty = !!size;
431+ if (!size)
432+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
435433 rec_total_size += size;
436434 if (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - start_request).count() > max_request_timeout)
437435 throw fcf::except::max_request_timeout_fi(a_socket->get_address(), a_socket->get_port(), request_header_info.host.c_str(), request_header_info.path.c_str());
438436 }
439437 } else if (rec_total_size < full_pack) {
440438 file_buffer.reset(new file_buffer_t());
441- bool firstEmpty = true;
442439 while (rec_total_size < full_pack) {
443440 size_t size = a_socket->recv(&big_data_buffer[0], full_pack - rec_total_size < MAX_PACK ? full_pack - rec_total_size : MAX_PACK);
444- if (!size && !firstEmpty)
445- throw std::runtime_error("Empty receive data (recv())");
446- firstEmpty = !!size;
441+ if (!size)
442+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
447443 rec_total_size += size;
448444 file_buffer->write(&big_data_buffer[0], size);
449445 if (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - start_request).count() > max_request_timeout)
@@ -474,13 +470,11 @@
474470 // send header with data
475471 offset = 0;
476472 {
477- bool firstEmpty = true;
478473 while(offset < first_buffer_offset){
479474 size_t size = process_socket->send(&first_buffer[offset], first_buffer_offset - offset);
480475 offset += size;
481- if (!size && !firstEmpty)
482- throw std::runtime_error("Empty send data to process (send())");
483- firstEmpty = !!size;
476+ if (!size)
477+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
484478 if (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - start_request).count() > max_request_timeout)
485479 throw fcf::except::max_request_timeout_fi(a_socket->get_address(), a_socket->get_port(), request_header_info.host.c_str(), request_header_info.path.c_str());
486480 }
@@ -490,13 +484,11 @@
490484 offset = 0;
491485 if (!is_big_data) {
492486 //residual_buffer
493- bool firstEmpty = true;
494487 while((offset + first_buffer_offset) < full_pack) {
495488 size_t size = process_socket->send(&residual_buffer[offset], (full_pack - first_buffer_offset) - offset);
496489 offset += size;
497- if (!size && !firstEmpty)
498- throw std::runtime_error("Empty send data to process (send())");
499- firstEmpty = !!size;
490+ if (!size)
491+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
500492 if (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - start_request).count() > max_request_timeout)
501493 throw fcf::except::max_request_timeout_fi(a_socket->get_address(), a_socket->get_port(), request_header_info.host.c_str(), request_header_info.path.c_str());
502494 }
@@ -506,13 +498,11 @@
506498 file_buffer->read(&big_data_buffer[0], pack_size);
507499
508500 size_t part_size = 0;
509- bool firstEmpty = true;
510501 while(part_size < pack_size) {
511502 size_t size = process_socket->send(&big_data_buffer[part_size], pack_size - part_size);
512503 part_size += size;
513- if (!size && !firstEmpty)
514- throw std::runtime_error("Empty send data to process (send())");
515- firstEmpty = !!size;
504+ if (!size)
505+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
516506 if (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - start_request).count() > max_request_timeout)
517507 throw fcf::except::max_request_timeout_fi(a_socket->get_address(), a_socket->get_port(), request_header_info.host.c_str(), request_header_info.path.c_str());
518508 }
@@ -550,7 +540,6 @@
550540 // send header with data to client
551541 full_pack = response_header_info.content_length + response_header_info.header_end + 4;
552542 offset = 0;
553- bool firstEmpty = true;
554543 while (offset < total_size) {
555544 if (!sps->active) {
556545 _buffered_forwarding(&first_buffer[offset],
@@ -568,16 +557,14 @@
568557 }
569558 size_t size = a_socket->send(&first_buffer[offset], total_size - offset > MAX_PACK ? MAX_PACK : (unsigned int)(total_size - offset));
570559 offset += size;
571- if (!size && !firstEmpty)
572- throw std::runtime_error("Empty send data to client (send())");
573- firstEmpty = !!size;
560+ if (!size)
561+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
574562 if (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - start_response).count() > max_response_timeout)
575563 throw fcf::except::max_response_timeout_fi(a_socket->get_address(), a_socket->get_port(), request_header_info.host.c_str(), request_header_info.path.c_str());
576564 }
577565
578566 // resend data to client
579567 if (!completed) {
580- bool firstEmpty = true;
581568 while(total_size < full_pack) {
582569 if (!sps->active) {
583570 _buffered_forwarding(&first_buffer[0],
@@ -595,9 +582,8 @@
595582 }
596583
597584 offset = process_socket->recv(&first_buffer[0], MAX_PACK);
598- if (!offset && !firstEmpty)
599- throw std::runtime_error("Empty receive data from process (send())");
600- firstEmpty = !!offset;
585+ if (!offset)
586+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
601587 if (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - start_response).count() > max_response_timeout)
602588 throw fcf::except::max_response_timeout_fi(a_socket->get_address(), a_socket->get_port(), request_header_info.host.c_str(), request_header_info.path.c_str());
603589
@@ -618,13 +604,11 @@
618604
619605 int sendc = 0;
620606 {
621- bool firstEmpty = true;
622607 while(sendc < offset){
623608 size_t size = a_socket->send(&first_buffer[sendc], offset - sendc);
624609 sendc += size;
625- if (!size && !firstEmpty)
626- throw std::runtime_error("Empty send data to client (send())");
627- firstEmpty = !!size;
610+ if (!size)
611+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
628612 if (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - start_response).count() > max_response_timeout)
629613 throw fcf::except::max_response_timeout_fi(a_socket->get_address(), a_socket->get_port(), request_header_info.host.c_str(), request_header_info.path.c_str());
630614 }
@@ -657,14 +641,11 @@
657641 // send header with data
658642 offset = 0;
659643 {
660- bool firstEmpty = true;
661644 while(offset < total_size){
662645 size_t size = process_socket->send(&first_buffer[offset], total_size - offset > MAX_PACK ? MAX_PACK : (unsigned int)(total_size - offset));
663646 offset += size;
664- if (!size && !firstEmpty)
665- throw std::runtime_error("Empty send data to process (send())");
666- firstEmpty = !!size;
667-
647+ if (!size)
648+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
668649 if (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - start_request).count() > max_request_timeout)
669650 throw fcf::except::max_request_timeout_fi(a_socket->get_address(), a_socket->get_port(), request_header_info.host.c_str(), request_header_info.path.c_str());
670651 }
@@ -673,24 +654,20 @@
673654 // resend data to process
674655 full_pack = request_header_info.content_length + request_header_info.header_end + 4;
675656 {
676- bool firstEmpty = true;
677657 while(total_size < full_pack){
678658 offset = a_socket->recv(&first_buffer[0], MAX_PACK);
679- if (!offset && !firstEmpty)
680- throw std::runtime_error("Empty receive data from client (recv())");
681- firstEmpty = !!offset;
659+ if (!offset)
660+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
682661 if (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - start_request).count() > max_request_timeout)
683662 throw fcf::except::max_request_timeout_fi(a_socket->get_address(), a_socket->get_port(), request_header_info.host.c_str(), request_header_info.path.c_str());
684663
685664 int sendc = 0;
686665 {
687- bool firstEmpty = true;
688666 while(sendc < offset){
689667 size_t size = process_socket->send(&first_buffer[sendc], offset - sendc);
690668 sendc += size;
691- if (!size && !firstEmpty)
692- throw std::runtime_error("Empty send data to process (send())");
693- firstEmpty = !!size;
669+ if (!size)
670+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
694671 if (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - start_request).count() > max_request_timeout)
695672 throw fcf::except::max_request_timeout_fi(a_socket->get_address(), a_socket->get_port(), request_header_info.host.c_str(), request_header_info.path.c_str());
696673 }
@@ -730,14 +707,11 @@
730707 // send header with data to client
731708 offset = 0;
732709 {
733- bool firstEmpty = true;
734710 while(offset < total_size){
735711 size_t size = a_socket->send(&first_buffer[offset], total_size - offset > MAX_PACK ? MAX_PACK : (unsigned int)(total_size - offset));
736712 offset += size;
737- if (!size && !firstEmpty)
738- throw std::runtime_error("Empty sending data to client(send())");
739- firstEmpty = !!size;
740-
713+ if (!size)
714+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
741715 if (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - start_response).count() > max_response_timeout)
742716 throw fcf::except::max_response_timeout_fi(a_socket->get_address(), a_socket->get_port(), request_header_info.host.c_str(), request_header_info.path.c_str());
743717 }
@@ -746,24 +720,20 @@
746720 // resend data to client
747721 full_pack = response_header_info.content_length + response_header_info.header_end + 4;
748722 {
749- bool firstEmpty = true;
750723 while(total_size < full_pack){
751724 offset = process_socket->recv(&first_buffer[0], MAX_PACK);
752- if (!offset && !firstEmpty)
753- throw std::runtime_error("Empty receive data from process(recv())");
754- firstEmpty = !!offset;
725+ if (!offset)
726+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
755727 if (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - start_request).count() > max_response_timeout)
756728 throw fcf::except::max_response_timeout_fi(a_socket->get_address(), a_socket->get_port(), request_header_info.host.c_str(), request_header_info.path.c_str());
757729
758730 int sendc = 0;
759731 {
760- bool firstEmpty = true;
761732 while(sendc < offset){
762733 size_t size = a_socket->send(&first_buffer[sendc], offset - sendc);
763734 sendc += size;
764- if (!size && !firstEmpty)
765- throw std::runtime_error("Empty receive data (recv())");
766- firstEmpty = !!size;
735+ if (!size)
736+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
767737 if (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - start_request).count() > max_response_timeout)
768738 throw fcf::except::max_response_timeout_fi(a_socket->get_address(), a_socket->get_port(), request_header_info.host.c_str(), request_header_info.path.c_str());
769739 }
Show on old repository browser