Fixed the broken pipe issue
This commit is contained in:
		
							parent
							
								
									ac89b3a423
								
							
						
					
					
						commit
						cbfd27b954
					
				@ -144,6 +144,8 @@ void LicenseServer::handleEventWrite(int fd, short, void* ptrServer) {
 | 
				
			|||||||
        	if(writtenBytes == -1 && errno == EAGAIN)
 | 
					        	if(writtenBytes == -1 && errno == EAGAIN)
 | 
				
			||||||
        		return;
 | 
					        		return;
 | 
				
			||||||
	        logError(LOG_LICENSE_CONTROLL, "Invalid write. Disconnecting remote client. Message: {}/{}", errno, strerror(errno));
 | 
						        logError(LOG_LICENSE_CONTROLL, "Invalid write. Disconnecting remote client. Message: {}/{}", errno, strerror(errno));
 | 
				
			||||||
 | 
						        server->unregisterClient(client);
 | 
				
			||||||
 | 
						        return;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            write_buffer->index += writtenBytes;
 | 
					            write_buffer->index += writtenBytes;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -187,7 +189,7 @@ void ConnectedClient::init() {
 | 
				
			|||||||
	TAILQ_INIT(&network.write_queue);
 | 
						TAILQ_INIT(&network.write_queue);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ConnectedClient::uninit() {
 | 
					void ConnectedClient::uninit(bool blocking) {
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        lock_guard queue_lock{this->network.write_queue_lock};
 | 
					        lock_guard queue_lock{this->network.write_queue_lock};
 | 
				
			||||||
        ts::buffer::RawBuffer* buffer;
 | 
					        ts::buffer::RawBuffer* buffer;
 | 
				
			||||||
@ -201,11 +203,17 @@ void ConnectedClient::uninit() {
 | 
				
			|||||||
        close(this->network.fileDescriptor);
 | 
					        close(this->network.fileDescriptor);
 | 
				
			||||||
	    network.fileDescriptor = 0;
 | 
						    network.fileDescriptor = 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if(this->network.readEvent) event_del(this->network.readEvent);
 | 
					 | 
				
			||||||
    this->network.readEvent = nullptr;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(this->network.writeEvent) event_del(this->network.writeEvent);
 | 
					    auto read_event = std::exchange(this->network.readEvent, nullptr);
 | 
				
			||||||
    this->network.writeEvent = nullptr;
 | 
					    auto write_event = std::exchange(this->network.writeEvent, nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if(blocking) {
 | 
				
			||||||
 | 
					        if(read_event) event_del_block(read_event);
 | 
				
			||||||
 | 
					        if(write_event) event_del_block(write_event);
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        if(read_event) event_del_noblock(read_event);
 | 
				
			||||||
 | 
					        if(write_event) event_del_noblock(write_event);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void LicenseServer::handleEventRead(int fd, short, void* ptrServer) {
 | 
					void LicenseServer::handleEventRead(int fd, short, void* ptrServer) {
 | 
				
			||||||
@ -312,7 +320,7 @@ void LicenseServer::unregisterClient(const std::shared_ptr<ConnectedClient> &cli
 | 
				
			|||||||
        std::lock_guard state_lock{client->protocol.state_lock};
 | 
					        std::lock_guard state_lock{client->protocol.state_lock};
 | 
				
			||||||
        client->protocol.state = protocol::UNCONNECTED;
 | 
					        client->protocol.state = protocol::UNCONNECTED;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    client->uninit();
 | 
					    client->uninit(this_thread::get_id() != this->event_base_dispatch.get_id());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void LicenseServer::cleanup_clients() {
 | 
					void LicenseServer::cleanup_clients() {
 | 
				
			||||||
 | 
				
			|||||||
@ -57,7 +57,7 @@ namespace license {
 | 
				
			|||||||
		    bool invalid_license = false;
 | 
							    bool invalid_license = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            void init();
 | 
					            void init();
 | 
				
			||||||
            void uninit();
 | 
					            void uninit(bool /* blocking */);
 | 
				
			||||||
            void sendPacket(const protocol::packet&);
 | 
					            void sendPacket(const protocol::packet&);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		    inline std::string address() { return inet_ntoa(network.remoteAddr.sin_addr); }
 | 
							    inline std::string address() { return inet_ntoa(network.remoteAddr.sin_addr); }
 | 
				
			||||||
 | 
				
			|||||||
@ -92,7 +92,6 @@ namespace license {
 | 
				
			|||||||
				std::deque<std::shared_ptr<Client>> clients;
 | 
									std::deque<std::shared_ptr<Client>> clients;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				threads::ThreadPool scheduler{1, "WebStatistics #"};
 | 
									threads::ThreadPool scheduler{1, "WebStatistics #"};
 | 
				
			||||||
 | 
					 | 
				
			||||||
			protected:
 | 
								protected:
 | 
				
			||||||
				static void handleEventAccept(int, short, void*);
 | 
									static void handleEventAccept(int, short, void*);
 | 
				
			||||||
				static void handleEventRead(int, short, void*);
 | 
									static void handleEventRead(int, short, void*);
 | 
				
			||||||
 | 
				
			|||||||
@ -673,7 +673,7 @@ void VoiceClientConnection::send_command(const std::string_view &command, bool l
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /* we don't need to make the command longer than it is */
 | 
					        /* we don't need to make the command longer than it is */
 | 
				
			||||||
        if(compressed_size < command.length() || this->client->getType() == ClientType::CLIENT_TEAMSPEAK) { /* TS3 requires each splituped packet to be compressed */
 | 
					        if(compressed_size < command.length() || this->client->getType() == ClientType::CLIENT_TEAMSPEAK) { /* TS3 requires each splituped packet to be compressed (Update: Not 100% sure since there was another bug when discovering this but I've kept it since) */
 | 
				
			||||||
            own_data_buffer = true;
 | 
					            own_data_buffer = true;
 | 
				
			||||||
            data_buffer = (char*) compressed_buffer;
 | 
					            data_buffer = (char*) compressed_buffer;
 | 
				
			||||||
            own_data_buffer_ptr = compressed_buffer;
 | 
					            own_data_buffer_ptr = compressed_buffer;
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								shared
									
									
									
									
									
								
							
							
								
								
								
								
								
								
									
									
								
							
						
						
									
										2
									
								
								shared
									
									
									
									
									
								
							@ -1 +1 @@
 | 
				
			|||||||
Subproject commit 5842bbe0676cb06c3947943fb5dd422aff0bef16
 | 
					Subproject commit bcbff04979d29d3a5a59cf0fa6daa35324bcf46c
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user