RE: [PATCH v3 2/4] tools: hv: Check return value of poll call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: Tomas Hozza [mailto:thozza@xxxxxxxxxx]
> Sent: Wednesday, May 22, 2013 8:55 AM
> To: gregkh@xxxxxxxxxxxxxxxxxxx
> Cc: KY Srinivasan; jasowang@xxxxxxxxxx; Haiyang Zhang;
> devel@xxxxxxxxxxxxxxxxxxxxxx; Tomas Hozza
> Subject: [PATCH v3 2/4] tools: hv: Check return value of poll call
> 
> Check return value of poll call and if it fails print error
> to the system log. If errno is EINVAL then exit with non-zero
> value otherwise continue the while loop and call poll again.
> 
> Signed-off-by: Tomas Hozza <thozza@xxxxxxxxxx>
Acked-by:  K. Y. Srinivasan <kys@xxxxxxxxxxxxx>

> ---
>  tools/hv/hv_kvp_daemon.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
> index ae9aa1c..81cbb6e 100644
> --- a/tools/hv/hv_kvp_daemon.c
> +++ b/tools/hv/hv_kvp_daemon.c
> @@ -1490,7 +1490,16 @@ int main(void)
>  		socklen_t addr_l = sizeof(addr);
>  		pfd.events = POLLIN;
>  		pfd.revents = 0;
> -		poll(&pfd, 1, -1);
> +
> +		if (poll(&pfd, 1, -1) < 0) {
> +			syslog(LOG_ERR, "poll failed; error: %d %s", errno,
> strerror(errno));
> +			if (errno == EINVAL) {
> +				close(fd);
> +				exit(EXIT_FAILURE);
> +			}
> +			else
> +				continue;
> +		}
> 
>  		len = recvfrom(fd, kvp_recv_buffer, sizeof(kvp_recv_buffer), 0,
>  				addr_p, &addr_l);
> --
> 1.8.1.4
> 
> 


_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux