X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device-src%2Fdevice.h;fp=device-src%2Fdevice.h;h=f53ca001f975ef0f2d9cc8099f2abfee70683e74;hb=d28952249e392eb31bc8eecc53f6c477f30c617b;hp=0945b0b1ef930fa12e6610bf0ff092d63bff0939;hpb=949b8910a5e23c4285d0b1aedacfc82a14dc97a5;p=debian%2Famanda diff --git a/device-src/device.h b/device-src/device.h index 0945b0b..f53ca00 100644 --- a/device-src/device.h +++ b/device-src/device.h @@ -1,9 +1,10 @@ /* * Copyright (c) 2007-2012 Zmanda, Inc. 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 version 2 as published - * by the Free Software Foundation. + * 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 @@ -205,18 +206,26 @@ struct _DeviceClass { guint64 (* get_bytes_written) (Device * self); gboolean (* listen)(Device *self, gboolean for_writing, DirectTCPAddr **addrs); - gboolean (* accept)(Device *self, DirectTCPConnection **conn, - ProlongProc prolong, gpointer prolong_data); - int (* accept_with_cond)(Device *self, DirectTCPConnection **conn, - GMutex *abort_mutex, GCond *abort_cond); - gboolean (* connect)(Device *self, gboolean for_writing, DirectTCPAddr *addrs, - DirectTCPConnection **conn, ProlongProc prolong, - gpointer prolong_data); - gboolean (* connect_with_cond)(Device *self, gboolean for_writing, + /* The MainLoop must be running, but the following 4 methods must not be + * called from an event. they must be called from a different thread. + * They return: + * 0 - success + * 1 - failed + * 2 - interupted + */ + int (* accept)(Device *self, DirectTCPConnection **conn, + int *cancelled, GMutex *abort_mutex, GCond *abort_cond); + int (* connect)(Device *self, gboolean for_writing, DirectTCPAddr *addrs, DirectTCPConnection **conn, + int *cancelled, GMutex *abort_mutex, GCond *abort_cond); - gboolean (* write_from_connection)(Device *self, guint64 size, guint64 *actual_size); - gboolean (* read_to_connection)(Device *self, guint64 size, guint64 *actual_size); + int (* write_from_connection)(Device *self, guint64 size, + guint64 *actual_size, int *cancelled, + GMutex *abort_mutex, GCond *abort_cond); + int (* read_to_connection)(Device *self, guint64 size, + guint64 *actual_size, int *cancelled, + GMutex *abort_mutex, GCond *abort_cond); + gboolean (* use_connection)(Device *self, DirectTCPConnection *conn); /* array of DeviceProperty objects for this class, keyed by ID */ @@ -346,18 +355,18 @@ gboolean device_eject (Device * self); #define device_directtcp_supported(self) (DEVICE_GET_CLASS((self))->directtcp_supported) gboolean device_listen(Device *self, gboolean for_writing, DirectTCPAddr **addrs); -gboolean device_accept(Device *self, DirectTCPConnection **conn, - ProlongProc prolong, gpointer prolong_data); -int device_accept_with_cond(Device *self, DirectTCPConnection **conn, - GMutex *abort_mutex, GCond *abort_cond); -gboolean device_connect(Device *self, gboolean for_writing, DirectTCPAddr *addrs, - DirectTCPConnection **conn, ProlongProc prolong, - gpointer prolong_data); -gboolean device_connect_with_cond(Device *self, gboolean for_writing, +int device_accept(Device *self, DirectTCPConnection **conn, + int *cancelled, GMutex *abort_mutex, GCond *abort_cond); +int device_connect(Device *self, gboolean for_writing, DirectTCPAddr *addrs, DirectTCPConnection **conn, + int *cancelled, + GMutex *abort_mutex, GCond *abort_cond); +int device_write_from_connection(Device *self, guint64 size, + guint64 *actual_size, int *cancelled, + GMutex *abort_mutex, GCond *abort_cond); +int device_read_to_connection(Device *self, guint64 size, + guint64 *actual_size, int *cancelled, GMutex *abort_mutex, GCond *abort_cond); -gboolean device_write_from_connection(Device *self, guint64 size, guint64 *actual_size); -gboolean device_read_to_connection(Device *self, guint64 size, guint64 *actual_size); gboolean device_use_connection(Device *self, DirectTCPConnection *conn); /* Protected methods. Don't call these except in subclass implementations. */