[gvfs] afp: Don't create write requests bigger than the maximum request size.
- From: Carl-Anton Ingmarsson <carlantoni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] afp: Don't create write requests bigger than the maximum request size.
- Date: Thu, 9 Aug 2012 20:16:54 +0000 (UTC)
commit 01fd300d7a015031827ba947c6cf38416ed8dd1a
Author: Carl-Anton Ingmarsson <ca ingmarsson gmail com>
Date: Thu Aug 9 20:22:17 2012 +0200
afp: Don't create write requests bigger than the maximum request size.
daemon/gvfsafpconnection.c | 6 ++++++
daemon/gvfsafpconnection.h | 4 ++++
daemon/gvfsafpserver.c | 30 +++++++++++++++++++++++-------
daemon/gvfsafpserver.h | 2 ++
daemon/gvfsafpvolume.c | 6 ++++--
5 files changed, 39 insertions(+), 9 deletions(-)
---
diff --git a/daemon/gvfsafpconnection.c b/daemon/gvfsafpconnection.c
index 34b7b31..e35dae3 100644
--- a/daemon/gvfsafpconnection.c
+++ b/daemon/gvfsafpconnection.c
@@ -1920,3 +1920,9 @@ g_vfs_afp_query_server_info (GSocketConnectable *addr,
return g_vfs_afp_reply_new (dsi_header.errorCode, data,
dsi_header.totalDataLength, TRUE);
}
+
+guint32
+g_vfs_afp_connection_get_max_request_size (GVfsAfpConnection *afp_connection)
+{
+ g_return_val_if_fail (G_VFS_IS_AFP_CONNECTION (afp_connection), 0);
+}
diff --git a/daemon/gvfsafpconnection.h b/daemon/gvfsafpconnection.h
index a524447..367f983 100644
--- a/daemon/gvfsafpconnection.h
+++ b/daemon/gvfsafpconnection.h
@@ -366,6 +366,10 @@ void g_vfs_afp_connection_send_command (GVfsAfpConnection *a
GAsyncReadyCallback callback,
GCancellable *cancellable,
gpointer user_data);
+
+
+guint32 g_vfs_afp_connection_get_max_request_size (GVfsAfpConnection *afp_connection);
+
G_END_DECLS
#endif /* _GVFSAFPCONNECTION_H_ */
diff --git a/daemon/gvfsafpserver.c b/daemon/gvfsafpserver.c
index ec50c30..a224249 100644
--- a/daemon/gvfsafpserver.c
+++ b/daemon/gvfsafpserver.c
@@ -1183,7 +1183,7 @@ done:
return res;
}
-/*
+/**
* g_vfs_afp_server_get_info:
*
* @server: a #GVfsAfpServer
@@ -1205,7 +1205,23 @@ g_vfs_afp_server_get_info (GVfsAfpServer *server)
return &priv->info;
}
-/*
+/**
+ * g_vfs_afp_server_get_max_request_size:
+ * @server: a #GVfsAfpServer
+ *
+ * Get the maximum request size the server supports.
+ *
+ * Returns: The maximum request size the server supports.
+ */
+guint32
+g_vfs_afp_server_get_max_request_size (GVfsAfpServer *server)
+{
+ g_return_val_if_fail (G_VFS_IS_AFP_SERVER (server), 0);
+
+ return g_vfs_afp_connection_get_max_request_size (server->priv->conn);
+}
+
+/**
* g_vfs_afp_server_time_to_local_time:
*
* @server: a #GVfsAfpServer
@@ -1301,7 +1317,7 @@ invalid_reply:
goto done;
}
-/*
+/**
* g_vfs_afp_server_get_volumes:
*
* @server: a #GVfsAfpServer
@@ -1332,7 +1348,7 @@ g_vfs_afp_server_get_volumes (GVfsAfpServer *server,
cancellable, simple);
}
-/*
+/**
* g_vfs_afp_server_get_volumes_finish:
*
* @server: a #GVfsAfpServer.
@@ -1503,7 +1519,7 @@ g_vfs_afp_server_fill_info (GVfsAfpServer *server,
{
guint16 offspring_count;
- g_vfs_afp_reply_read_uint16 (reply, &offspring_count);
+ REPLY_READ_UINT16 (reply, &offspring_count);
g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_AFP_CHILDREN_COUNT,
offspring_count);
}
@@ -1692,7 +1708,7 @@ invalid_reply:
goto done;
}
-/*
+/**
* g_vfs_afp_server_map_id:
*
* @server: a #GVfsAfpServer.
@@ -1746,7 +1762,7 @@ g_vfs_afp_server_map_id (GVfsAfpServer *server,
g_object_unref (comm);
}
-/*
+/**
* g_vfs_afp_server_map_id_finish:
*
* @server: a #GVfsAfpServer.
diff --git a/daemon/gvfsafpserver.h b/daemon/gvfsafpserver.h
index 2a57f99..9cb1426 100644
--- a/daemon/gvfsafpserver.h
+++ b/daemon/gvfsafpserver.h
@@ -94,6 +94,8 @@ gint64 g_vfs_afp_server_time_to_local_time (GVfsAfpServer *server,
const
GVfsAfpServerInfo* g_vfs_afp_server_get_info (GVfsAfpServer *server);
+guint32 g_vfs_afp_server_get_max_request_size (GVfsAfpServer *server);
+
typedef struct _GVfsAfpVolumeData GVfsAfpVolumeData;
struct _GVfsAfpVolumeData
{
diff --git a/daemon/gvfsafpvolume.c b/daemon/gvfsafpvolume.c
index fe9eacb..1a2eac0 100644
--- a/daemon/gvfsafpvolume.c
+++ b/daemon/gvfsafpvolume.c
@@ -2691,7 +2691,7 @@ g_vfs_afp_volume_write_to_fork (GVfsAfpVolume *volume,
gpointer user_data)
{
GVfsAfpCommand *comm;
- guint32 req_count;
+ guint32 max_req_count, req_count;
GSimpleAsyncResult *simple;
g_return_if_fail (G_VFS_IS_AFP_VOLUME (volume));
@@ -2704,11 +2704,13 @@ g_vfs_afp_volume_write_to_fork (GVfsAfpVolume *volume,
g_vfs_afp_command_put_int16 (comm, fork_refnum);
/* Offset */
g_vfs_afp_command_put_int64 (comm, offset);
+
/* ReqCount */
+ max_req_count = g_vfs_afp_server_get_max_request_size (volume->priv->server) - 20;
req_count = MIN (buffer_size, G_MAXUINT32);
g_vfs_afp_command_put_int64 (comm, req_count);
- g_vfs_afp_command_set_buffer (comm, buffer, buffer_size);
+ g_vfs_afp_command_set_buffer (comm, buffer, req_count);
simple = g_simple_async_result_new (G_OBJECT (volume), callback, user_data,
g_vfs_afp_volume_write_to_fork);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]