mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 10:47:18 +00:00 
			
		
		
		
	res_audiosocket.c: Add retry mechanism for reading data from AudioSocket
The added retry mechanism addresses an issue that arises when fragmented TCP packets are received, each containing only a portion of an AudioSocket packet. This situation can occur if the external service sending the AudioSocket data has Nagle's algorithm enabled.
This commit is contained in:
		
				
					committed by
					
						![github-actions[bot]](/avatar/af2ab225b7c0eec44a8d0eba6b5c869a?size=40) github-actions[bot]
						github-actions[bot]
					
				
			
			
				
	
			
			
			
						parent
						
							c4db87ae53
						
					
				
				
					commit
					3924a828ff
				
			| @@ -315,6 +315,18 @@ struct ast_frame *ast_audiosocket_receive_frame_with_hangup(const int svc, | ||||
| 	while (i < *length) { | ||||
| 		n = read(svc, data + i, *length - i); | ||||
| 		if (n == -1) { | ||||
| 			if (errno == EAGAIN || errno == EWOULDBLOCK) { | ||||
| 				int poll_result = ast_wait_for_input(svc, 5); | ||||
|  | ||||
| 				if (poll_result == 1) { | ||||
| 					continue; | ||||
| 				} else if (poll_result == 0) { | ||||
| 					ast_log(LOG_WARNING, "Poll timed out while waiting for data\n"); | ||||
| 				} else { | ||||
| 					ast_log(LOG_WARNING, "Poll error: %s\n", strerror(errno)); | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			ast_log(LOG_ERROR, "Failed to read payload from AudioSocket: %s\n", strerror(errno)); | ||||
| 			ret = -1; | ||||
| 			break; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user