Implement irc_try_write()
This commit is contained in:
		
							
								
								
									
										22
									
								
								src/kike.c
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								src/kike.c
									
									
									
									
									
								
							@@ -456,7 +456,27 @@ irc_try_read_ssl (struct connection *conn)
 | 
				
			|||||||
static bool
 | 
					static bool
 | 
				
			||||||
irc_try_write (struct connection *conn)
 | 
					irc_try_write (struct connection *conn)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// TODO
 | 
						struct str *buf = &conn->write_buffer;
 | 
				
			||||||
 | 
						ssize_t n_written;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						while (buf->len)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							n_written = send (conn->socket_fd, buf->str, buf->len, 0);
 | 
				
			||||||
 | 
							if (n_written >= 0)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								str_remove_slice (buf, 0, n_written);
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (errno == EAGAIN)
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							if (errno == EINTR)
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							print_debug ("%s: %s: %s", __func__, "send", strerror (errno));
 | 
				
			||||||
 | 
							connection_kill (conn, strerror (errno));
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	return true;
 | 
						return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user