[PATCH] supplicant: Make unix socket non-blocking.

Ben Greear greearb
Fri Apr 6 13:18:20 PDT 2012


On 02/05/2012 09:18 AM, Jouni Malinen wrote:
> On Thu, Jan 05, 2012 at 10:52:46AM -0800, greearb at candelatech.com wrote:
>> This keeps wpa_cli from hanging forever if the other end of the
>> socket dies.
>
> Hmm.. The change here is for wpa_cli:
>
>> diff --git a/src/common/wpa_ctrl.c b/src/common/wpa_ctrl.c
>> @@ -321,7 +322,29 @@ int wpa_ctrl_request(struct wpa_ctrl *ctrl, const char *cmd, size_t cmd_len,
>> +retry_send:
>>   	if (send(ctrl->s, _cmd, _cmd_len, 0)<  0) {
>> +		if ((errno == EAGAIN) || (errno = EBUSY)
>> +		    || (errno == EWOULDBLOCK)) {
>> +			/* Must be non-blocking socket...try for a bit longer
>> +			 * before giving up.
>> +			 */
>
> ...
>
> while the part that makes the socket non-blocking is for wpa_supplicant:
>
>> diff --git a/wpa_supplicant/ctrl_iface_unix.c b/wpa_supplicant/ctrl_iface_unix.c
>> @@ -411,6 +413,17 @@ wpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s)
>> +	/* Make socket non-blocking so that we don't hang forever if
>> +	 * target dies unexpectedly.
>> +	 */
>> +	flags = fcntl(priv->sock, F_GETFL);
>> +	flags |= (O_NONBLOCK);
>> +	if (fcntl(priv->sock, F_SETFL, flags)<  0) {
>
> Am I missing something here or how is this supposed to work? Shouldn't
> these changes be for the same socket, i.e., the one used by wpa_cli, or
> were you thinking of making both wpa_cli and wpa_supplicant use
> non-blocking sockets (in which case this fnctl call would need to be in
> wpa_ctrl.c, too, I'd assume)?


I think you are right.  I should be adding the fcntl to wpa_ctrl.c
as well.

I've updated the patch in my tree and will re-post after
it gets a bit of testing time.

Thanks,
Ben


-- 
Ben Greear <greearb at candelatech.com>
Candela Technologies Inc  http://www.candelatech.com




More information about the Hostap mailing list