Hi Bastien,

I have some comments for your patches.

Am Freitag 19 Februar 2010 18:21:20 schrieb Bastien Nocera:
> A few self-explanatory patches.
> 
> See http://thread.gmane.org/gmane.linux.bluez.kernel/4650 for the
> original post
> 
[...]
> From: Bastien Nocera <had...@hadess.net>
> Date: Fri, 19 Feb 2010 12:04:43 +0000
> Subject: [PATCH 2/2] Export the libusb1 read file descriptor
> 
> When using libusb1, we can export the file descriptor that
> corresponds to reading from the device, so it can be used to
> setup polling sources, and timeout based operations.
> 
> This would be used by osso-gwobex to monitor incoming data, for
> USB support.
> ---
>  lib/usb1obex.c |   31 +++++++++++++++++++++++++++++++
>  1 files changed, 31 insertions(+), 0 deletions(-)
> 
> diff --git a/lib/usb1obex.c b/lib/usb1obex.c
> index dfa1685..6a80fbb 100644
> --- a/lib/usb1obex.c
> +++ b/lib/usb1obex.c
> @@ -30,6 +30,7 @@
>  #include <stdio.h>             /* perror */
>  #include <errno.h>             /* errno and EADDRNOTAVAIL */
>  #include <stdlib.h>
> +#include <poll.h>              /* POLLOUT */
>  
>  #include <libusb.h>
>  
> @@ -339,6 +340,35 @@ void usbobex_free_interfaces(int num, obex_interface_t
>  *intf) }
>  
>  /*
> + * Function usbobex_get_fd ()
> + *
> + *    Get the "poll out" file descriptor for the USB device,
> + *    used to check for events in an async way
> + *
> + */
> +static int usbobex_get_fd(void)
> +{
> +       const struct libusb_pollfd **usbfds;
> +       const struct libusb_pollfd *usbfd;
> +       int i = 0;
> +
> +       DEBUG(4, "Getting the USB file descriptor");
> +
> +       usbfds = libusb_get_pollfds(libusb_ctx);
> +       if (usbfds == NULL) {
> +               DEBUG(4, "Could not get USB file descriptors");
> +               return INVALID_SOCKET;
> +       }
> +
> +       while ((usbfd = usbfds[i++]) != NULL) {
> +               if (usbfd->events & POLLOUT)

This is not correct. The file descriptor is used in 
obex_transport_handle_input() in context of the select() funcion. But that 
only waits for incoming data, not for outgoing. So you are choosing the wrong 
file descriptor, here, use the one for POLLIN instead.

> +                       return usbfd->fd;
> +       }
> +
> +       return INVALID_SOCKET;
> +}
> +
> +/*
>   * Function usbobex_connect_request (self)
>   *
>   *    Open the USB connection
> @@ -379,6 +409,7 @@ int usbobex_connect_request(obex_t *self)
>         }
>  
>         self->trans.mtu = OBEX_MAXIMUM_MTU;
> +       self->fd = usbobex_get_fd();
>         DEBUG(2, "transport mtu=%d\n", self->trans.mtu);
>         return 1;

Additionally to setting self->fd here, you should also modify 
obex_transport_handle_input() to no choose the special USB path when
self->fd is valid.

> From: Bastien Nocera <had...@hadess.net>
> Date: Fri, 19 Feb 2010 13:40:27 +0000
> Subject: [PATCH] Fix invalid memory access
> 
> The hdr pointer will not be valid any more if the transport
> read() does a realloc, so cache the opcode that we'll use
> later in the code.

Not the correct approach, in my eyes. Instead, update msg (also used after 
this point) and hdr variables.
Good finding :)

HS

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Openobex-users mailing list
Openobex-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/openobex-users

Reply via email to