Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Burton2013-09-09 19:02:46 -0400
committerFelix Burton2013-09-09 19:02:46 -0400
commit77a0d8e0af3bd173559edeb3874c55c346d790e0 (patch)
treea8f3cf5979574c8a7ee34ca30a1d15f0c7164689
parent55bc424cc7dd796fd8aa2dcd7a276d49f32812d9 (diff)
downloadorg.eclipse.tcf.agent-77a0d8e0af3bd173559edeb3874c55c346d790e0.tar.gz
org.eclipse.tcf.agent-77a0d8e0af3bd173559edeb3874c55c346d790e0.tar.xz
org.eclipse.tcf.agent-77a0d8e0af3bd173559edeb3874c55c346d790e0.zip
Add protocol_send_command_with_progress() to support handling of progress messages
Prior to this change the reply handler was called for both progress and reply messages. However, there was no flag to differentiate progress messages from reply messages, without interpreting the message body. With this change the reply handler is no longer called for progress messages. This is not 100% backwards compatible. At this time we are not aware of any service using progress messages, so it will hopefully not affect anybody in a negative way.
-rw-r--r--agent/tcf/framework/protocol.c18
-rw-r--r--agent/tcf/framework/protocol.h11
2 files changed, 25 insertions, 4 deletions
diff --git a/agent/tcf/framework/protocol.c b/agent/tcf/framework/protocol.c
index f1e72851..a9c131c8 100644
--- a/agent/tcf/framework/protocol.c
+++ b/agent/tcf/framework/protocol.c
@@ -69,6 +69,7 @@ struct ReplyHandlerInfo {
unsigned long tokenid;
Channel * c;
ReplyHandlerCB handler;
+ ProgressHandlerCB progress;
void * client_data;
struct ReplyHandlerInfo * next;
};
@@ -277,6 +278,14 @@ void handle_protocol_message(Channel * c) {
exception(ERR_PROTOCOL);
}
}
+ else if (type[0] == 'P') {
+ if (rh->progress) {
+ rh->progress(c, rh->client_data);
+ }
+ else {
+ skip_until_EOM(c);
+ }
+ }
else {
int n = 0;
if (type[0] == 'N') {
@@ -284,7 +293,7 @@ void handle_protocol_message(Channel * c) {
n = ERR_INV_COMMAND;
}
rh->handler(c, rh->client_data, n);
- if (type[0] != 'P') loc_free(rh);
+ loc_free(rh);
}
clear_trap(&trap);
}
@@ -421,12 +430,13 @@ static void send_command_failed(void * args) {
loc_free(rh);
}
-ReplyHandlerInfo * protocol_send_command(Channel * c, const char * service, const char * name, ReplyHandlerCB handler, void * client_data) {
+ReplyHandlerInfo * protocol_send_command_with_progress(Channel * c, const char * service, const char * name, ReplyHandlerCB handler, ProgressHandlerCB progress, void * client_data) {
Protocol * p = c->protocol;
ReplyHandlerInfo * rh = (ReplyHandlerInfo *)loc_alloc(sizeof(ReplyHandlerInfo));
rh->c = c;
rh->handler = handler;
+ rh->progress = progress;
rh->client_data = client_data;
if (is_channel_closed(c) || c->peer_service_list == NULL) {
post_event(send_command_failed, rh);
@@ -449,6 +459,10 @@ ReplyHandlerInfo * protocol_send_command(Channel * c, const char * service, cons
return rh;
}
+ReplyHandlerInfo * protocol_send_command(Channel * c, const char * service, const char * name, ReplyHandlerCB handler, void * client_data) {
+ return protocol_send_command_with_progress(c, service, name, handler, NULL, client_data);
+}
+
struct sendRedirectInfo {
ReplyHandlerCB handler;
void * client_data;
diff --git a/agent/tcf/framework/protocol.h b/agent/tcf/framework/protocol.h
index c8c15907..938772fd 100644
--- a/agent/tcf/framework/protocol.h
+++ b/agent/tcf/framework/protocol.h
@@ -44,13 +44,17 @@ typedef void (*ProtocolCommandHandler2)(char *, Channel *, void * client_data);
typedef void (*ProtocolEventHandler2)(Channel *, void * client_data);
/*
- * Callback fucntion for replies of commands. If error is non-zero
+ * Callback function for replies of commands. If error is non-zero
* then no data should be read of the input steam.
*/
-/* TODO: need additional argument in ReplyHandlerCB to distinguish R and P responses */
typedef void (*ReplyHandlerCB)(Channel *, void * client_data, int error);
/*
+ * Callback function for progress of commands.
+ */
+typedef void (*ProgressHandlerCB)(Channel *, void * client_data);
+
+/*
* Read and dispatch one protocol message.
* This function is by channel manager when a message is available for handling.
*/
@@ -99,6 +103,9 @@ extern void set_default_message_handler2(Protocol *, ProtocolMessageHandler2 han
*/
extern ReplyHandlerInfo * protocol_send_command(Channel * c,
const char * service, const char * name, ReplyHandlerCB handler, void * client_data);
+extern ReplyHandlerInfo * protocol_send_command_with_progress(Channel * c,
+ const char * service, const char * name, ReplyHandlerCB handler,
+ ProgressHandlerCB progress, void * client_data);
/*
* Cancel pending command. Returns true if the commands was cancelled

Back to the top