From owner-freebsd-usb@FreeBSD.ORG Fri Jul 23 18:21:50 2010 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A70411065678 for ; Fri, 23 Jul 2010 18:21:50 +0000 (UTC) (envelope-from peerst@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 3AAC88FC16 for ; Fri, 23 Jul 2010 18:21:49 +0000 (UTC) Received: by wyj26 with SMTP id 26so565470wyj.13 for ; Fri, 23 Jul 2010 11:21:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=Jbt1O8ZI9hUYhsT2lsWzKIoSJAjV7zPpcJTCJxyXtk8=; b=jpyhPfL17wmKe1JpkTbY8HMfs74MZF23gSv4/cwWSaTa0XBwkzck1pnGipSeDOT1Ls DTjwLZTlkYI/Q71B2Kx1/IrawB+EBZtNgeuit+4qx68UUtawhptyyPIhK7ctj3EM9uqn +N+fftvfLbf7Ma00l3rsvJYogCECZJg6T3w6w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=pHFnFLHUPZfImiIMVtDD1xLW6IIdnk8zk6Zjwdu13E01/PzZhlTHu+i9DiGTAaPAdb V/qAMuzQDSwDHZu37PC8/hzhk+QxUeYRjln9k3MPLbHJgcSZnQ5mStZBemLwOCpQPwde uDIZZsOtfY4YdhWxkPzCuSLsFbQKPxnuul2NU= MIME-Version: 1.0 Received: by 10.227.158.14 with SMTP id d14mr1040024wbx.33.1279909308826; Fri, 23 Jul 2010 11:21:48 -0700 (PDT) Received: by 10.227.1.225 with HTTP; Fri, 23 Jul 2010 11:21:48 -0700 (PDT) In-Reply-To: <201007231921.45803.hselasky@c2i.net> References: <201007231657.47682.hselasky@c2i.net> <201007231921.45803.hselasky@c2i.net> Date: Fri, 23 Jul 2010 20:21:48 +0200 Message-ID: From: Peer Stritzinger To: Hans Petter Selasky Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-usb@freebsd.org Subject: Re: FreeBSD 8: libusb async mode + select(2) = nogo? X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Jul 2010 18:21:50 -0000 Hi, On Fri, Jul 23, 2010 at 7:21 PM, Hans Petter Selasky wro= te: > Should work, but it might be that the second poll, when you try to proces= s the > events, don't work like expected. After any event on the two fd's you sho= uld > call "libusb_handle_events_locked()" using a "tv =3D NULL". Added some debug printing to make watching these easier: active config: num_interfaces: 1 interface 0: num_altsetting: 1 if_desc 0: n_ep=3D4 if_nr=3D0 max packet on 3.2.6 =3D 512 setup_usb_fds: read 3 setup_usb_fds: read 6 setup_usb_fds: write 6 setup_usb_fds: nfds 6 calling select ... returned 1 -> so select returns once (always as it looks) check_usb_fds: found desc 3 in readfds calling libusb_handle_events_timeout transfer_completed: actual_len: 52 -> and also gets a transfer from the usb (this resubmits the IN transfer) setup_usb_fds: read 3 setup_usb_fds: read 6 setup_usb_fds: write 6 setup_usb_fds: nfds 6 calling select ... -> but here it hangs until a signal The code that did output this still using libusb_handle_events_timeout() rv =3D libusb_submit_transfer(tr); assert(rv =3D=3D 0); sp.pollfds =3D libusb_get_pollfds(ctx); while (1) { timeout_pending =3D libusb_get_next_timeout(ctx, &timeout); setup_usb_fds (&sp); printf("calling select ...\n"); rv =3D select(sp.nfds, &sp.readfds, &sp.writefds, &sp.exceptfds, (timeout_pending) ? &timeout : NULL); printf("returned %d\n", rv); assert (rv >=3D 0 || errno =3D=3D EINTR); if (rv =3D=3D 0 || (rv > 0 && check_usb_fds (&sp))) { printf ("calling libusb_handle_events_timeout\n"); libusb_handle_events_timeout(ctx, NULL); } } =A0-- Peer