summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerome Guiban2013-06-17 12:07:39 (EDT)
committer Eugene Tarassov2013-06-19 13:34:37 (EDT)
commitd3015bf20f1ca18eb438d1377ceb334cd3dc8c68 (patch)
tree17db2bc3d8c1f0b10f18a9e29413bbf204c57b0c
parentbb73e4d940391f4decae90027a92236cd4055e6c (diff)
downloadorg.eclipse.tcf.agent-d3015bf20f1ca18eb438d1377ceb334cd3dc8c68.zip
org.eclipse.tcf.agent-d3015bf20f1ca18eb438d1377ceb334cd3dc8c68.tar.gz
org.eclipse.tcf.agent-d3015bf20f1ca18eb438d1377ceb334cd3dc8c68.tar.bz2
filesystem: prevent extra channel close listener
This commit: - Prevents multiple registrations of channel close listener for the filesystem service. - move few constants definitions from source file to header.
-rw-r--r--agent/tcf/services/filesystem.c23
-rw-r--r--agent/tcf/services/filesystem.h20
2 files changed, 27 insertions, 16 deletions
diff --git a/agent/tcf/services/filesystem.c b/agent/tcf/services/filesystem.c
index d23e51b..c7a51a6 100644
--- a/agent/tcf/services/filesystem.c
+++ b/agent/tcf/services/filesystem.c
@@ -61,24 +61,11 @@
static const char * FILE_SYSTEM = "FileSystem";
static const int
- TCF_O_READ = 0x00000001,
- TCF_O_WRITE = 0x00000002,
- TCF_O_APPEND = 0x00000004,
- TCF_O_CREAT = 0x00000008,
- TCF_O_TRUNC = 0x00000010,
- TCF_O_EXCL = 0x00000020;
-
-static const int
ATTR_SIZE = 0x00000001,
ATTR_UIDGID = 0x00000002,
ATTR_PERMISSIONS = 0x00000004,
ATTR_ACMODTIME = 0x00000008;
-static const int
- FSERR_EOF = 0x10001,
- FSERR_NO_SUCH_FILE = 0x10002,
- FSERR_PERMISSION_DENIED = 0x10003;
-
#define REQ_READ 1
#define REQ_WRITE 2
#define REQ_FSTAT 3
@@ -1369,10 +1356,14 @@ static void command_roots(char * token, Channel * c) {
void ini_file_system_service(Protocol * proto) {
int i;
+ static int ini_file_system = 0;
- add_channel_close_listener(channel_close_listener);
- for (i = 0; i < HANDLE_HASH_SIZE; i++) {
- list_init(&handle_hash[i]);
+ if (ini_file_system == 0) {
+ add_channel_close_listener(channel_close_listener);
+ for (i = 0; i < HANDLE_HASH_SIZE; i++) {
+ list_init(&handle_hash[i]);
+ }
+ ini_file_system = 1;
}
add_command_handler(proto, FILE_SYSTEM, "open", command_open);
diff --git a/agent/tcf/services/filesystem.h b/agent/tcf/services/filesystem.h
index 3f63c37..979a7a2 100644
--- a/agent/tcf/services/filesystem.h
+++ b/agent/tcf/services/filesystem.h
@@ -21,6 +21,26 @@
#define D_filesystem
#include <tcf/framework/protocol.h>
+
+/*
+ * Open modes
+ */
+static const int
+ TCF_O_READ = 0x00000001,
+ TCF_O_WRITE = 0x00000002,
+ TCF_O_APPEND = 0x00000004,
+ TCF_O_CREAT = 0x00000008,
+ TCF_O_TRUNC = 0x00000010,
+ TCF_O_EXCL = 0x00000020;
+
+/*
+ * Error codes
+ */
+static const int
+ FSERR_EOF = 0x10001,
+ FSERR_NO_SUCH_FILE = 0x10002,
+ FSERR_PERMISSION_DENIED = 0x10003;
+
/*
* Initialize file system service.
*/