mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-23 20:24:21 +08:00
7a35c12a6c
When a obex transfer is interrupted by a peer in the middle, the response G_OBEX_RSP_FORBIDDEN comes and the transfer is freed in transfer_complete. However gobex is still ref'ed and gobex->io continues to be writable, so write_data() and then g_obex_abort() are called. When the abort response comes, struct obc_transfer is already freed, which leads to the crash. Backtrace : __GI___pthread_mutex_lock (mutex=0x65732f74) at pthread_mutex_lock.c:67 0xecc6eeda in dbus_connection_get_object_path_data () from libdbus-1.so.3 0x000457d4 in g_dbus_emit_property_changed_full () at gdbus/object.c:1794 0x00045868 in g_dbus_emit_property_changed () at gdbus/object.c:1832 0x000367f0 in transfer_set_status () at obexd/client/transfer.c:211 0x0003681e in transfer_set_status () at obexd/client/transfer.c:206 xfer_complete () at obexd/client/transfer.c:672 0x00022df6 in transfer_complete () at gobex/gobex-transfer.c:103 0x00022f44 in transfer_abort_response () at gobex/gobex-transfer.c:124 0x00020a0e in handle_response () at gobex/gobex.c:1128 0x00020dde in incoming_data () at gobex/gobex.c:1373 This commit introduces g_obex_drop_tx_queue(), which will be called if a transfer error detected. After the tx queue is dropped, obex shuts down gracefully.
140 lines
4.6 KiB
C
140 lines
4.6 KiB
C
/*
|
|
*
|
|
* OBEX library with GLib integration
|
|
*
|
|
* Copyright (C) 2011 Intel Corporation. All rights reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*
|
|
*/
|
|
|
|
#ifndef __GOBEX_H
|
|
#define __GOBEX_H
|
|
|
|
#include <stdarg.h>
|
|
#include <glib.h>
|
|
|
|
#include "gobex/gobex-defs.h"
|
|
#include "gobex/gobex-packet.h"
|
|
|
|
typedef enum {
|
|
G_OBEX_TRANSPORT_STREAM,
|
|
G_OBEX_TRANSPORT_PACKET,
|
|
} GObexTransportType;
|
|
|
|
typedef struct _GObex GObex;
|
|
|
|
typedef void (*GObexFunc) (GObex *obex, GError *err, gpointer user_data);
|
|
typedef void (*GObexRequestFunc) (GObex *obex, GObexPacket *req,
|
|
gpointer user_data);
|
|
typedef void (*GObexResponseFunc) (GObex *obex, GError *err, GObexPacket *rsp,
|
|
gpointer user_data);
|
|
|
|
gboolean g_obex_send(GObex *obex, GObexPacket *pkt, GError **err);
|
|
|
|
guint g_obex_send_req(GObex *obex, GObexPacket *req, int timeout,
|
|
GObexResponseFunc func, gpointer user_data,
|
|
GError **err);
|
|
gboolean g_obex_cancel_req(GObex *obex, guint req_id,
|
|
gboolean remove_callback);
|
|
|
|
gboolean g_obex_send_rsp(GObex *obex, guint8 rspcode, GError **err,
|
|
guint first_hdr_type, ...);
|
|
|
|
void g_obex_set_disconnect_function(GObex *obex, GObexFunc func,
|
|
gpointer user_data);
|
|
guint g_obex_add_request_function(GObex *obex, guint8 opcode,
|
|
GObexRequestFunc func,
|
|
gpointer user_data);
|
|
gboolean g_obex_remove_request_function(GObex *obex, guint id);
|
|
|
|
void g_obex_suspend(GObex *obex);
|
|
void g_obex_resume(GObex *obex);
|
|
gboolean g_obex_srm_active(GObex *obex);
|
|
void g_obex_drop_tx_queue(GObex *obex);
|
|
|
|
GObex *g_obex_new(GIOChannel *io, GObexTransportType transport_type,
|
|
gssize rx_mtu, gssize tx_mtu);
|
|
|
|
GObex *g_obex_ref(GObex *obex);
|
|
void g_obex_unref(GObex *obex);
|
|
|
|
/* High level client functions */
|
|
|
|
guint g_obex_connect(GObex *obex, GObexResponseFunc func, gpointer user_data,
|
|
GError **err, guint first_hdr_id, ...);
|
|
|
|
guint g_obex_disconnect(GObex *obex, GObexResponseFunc func, gpointer user_data,
|
|
GError **err);
|
|
|
|
guint g_obex_setpath(GObex *obex, const char *path, GObexResponseFunc func,
|
|
gpointer user_data, GError **err);
|
|
|
|
guint g_obex_mkdir(GObex *obex, const char *path, GObexResponseFunc func,
|
|
gpointer user_data, GError **err);
|
|
|
|
guint g_obex_delete(GObex *obex, const char *name, GObexResponseFunc func,
|
|
gpointer user_data, GError **err);
|
|
|
|
guint g_obex_copy(GObex *obex, const char *name, const char *dest,
|
|
GObexResponseFunc func, gpointer user_data,
|
|
GError **err);
|
|
|
|
guint g_obex_move(GObex *obex, const char *name, const char *dest,
|
|
GObexResponseFunc func, gpointer user_data,
|
|
GError **err);
|
|
|
|
guint g_obex_abort(GObex *obex, GObexResponseFunc func, gpointer user_data,
|
|
GError **err);
|
|
|
|
/* Transfer related high-level functions */
|
|
|
|
guint g_obex_put_req(GObex *obex, GObexDataProducer data_func,
|
|
GObexFunc complete_func, gpointer user_data,
|
|
GError **err, guint first_hdr_id, ...);
|
|
|
|
guint g_obex_put_req_pkt(GObex *obex, GObexPacket *req,
|
|
GObexDataProducer data_func, GObexFunc complete_func,
|
|
gpointer user_data, GError **err);
|
|
|
|
guint g_obex_get_req(GObex *obex, GObexDataConsumer data_func,
|
|
GObexFunc complete_func, gpointer user_data,
|
|
GError **err, guint first_hdr_id, ...);
|
|
|
|
guint g_obex_get_req_pkt(GObex *obex, GObexPacket *req,
|
|
GObexDataConsumer data_func, GObexFunc complete_func,
|
|
gpointer user_data, GError **err);
|
|
|
|
guint g_obex_put_rsp(GObex *obex, GObexPacket *req,
|
|
GObexDataConsumer data_func, GObexFunc complete_func,
|
|
gpointer user_data, GError **err,
|
|
guint first_hdr_id, ...);
|
|
|
|
guint g_obex_get_rsp(GObex *obex, GObexDataProducer data_func,
|
|
GObexFunc complete_func, gpointer user_data,
|
|
GError **err, guint first_hdr_id, ...);
|
|
|
|
guint g_obex_get_rsp_pkt(GObex *obex, GObexPacket *rsp,
|
|
GObexDataProducer data_func, GObexFunc complete_func,
|
|
gpointer user_data, GError **err);
|
|
|
|
gboolean g_obex_cancel_transfer(guint id, GObexFunc complete_func,
|
|
gpointer user_data);
|
|
|
|
const char *g_obex_strerror(guint8 err_code);
|
|
guint8 g_obex_errno_to_rsp(int err);
|
|
|
|
#endif /* __GOBEX_H */
|