|
@@ -15,6 +15,8 @@
|
|
|
|
|
|
#include "myco-agent.h"
|
|
|
|
|
|
+#define DEBUG 1
|
|
|
+
|
|
|
int myco_agent_register(const char *agent_name) {
|
|
|
int agent_message_queue_id;
|
|
|
int global_message_queue_id;
|
|
@@ -28,9 +30,8 @@ int myco_agent_register(const char *agent_name) {
|
|
|
|
|
|
msg = myco_send_and_receive(msg, myco_get_global_message_queue(), agent_message_queue_id);
|
|
|
|
|
|
- if (strncmp(msg.message, "SUCCESS:", 8) != 0) {
|
|
|
+ if (DEBUG) {
|
|
|
printf("%s", msg.message);
|
|
|
- return -1;
|
|
|
}
|
|
|
|
|
|
return agent_message_queue_id;
|
|
@@ -44,15 +45,11 @@ int myco_agent_unregister (const char *agent_name, int agent_message_queue_id) {
|
|
|
|
|
|
msg = myco_send_and_receive(msg, myco_get_global_message_queue(), agent_message_queue_id);
|
|
|
|
|
|
- if (strncmp(msg.message, "SUCCESS:", 8) != 0) {
|
|
|
+ if (DEBUG) {
|
|
|
printf("%s\n", msg.message);
|
|
|
- return -1;
|
|
|
}
|
|
|
|
|
|
- if (myco_remove_message_queue(agent_message_queue_id) == -1) {
|
|
|
- printf("FATAL ERROR: could not remove message queue %d\n", agent_message_queue_id);
|
|
|
- return -1;
|
|
|
- }
|
|
|
+ myco_remove_message_queue(agent_message_queue_id);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
@@ -67,9 +64,8 @@ int myco_agent_register_resource (int agent_message_queue_id, const char *agent_
|
|
|
|
|
|
msg = myco_send_and_receive(msg, myco_get_global_message_queue(), agent_message_queue_id);
|
|
|
|
|
|
- if (strncmp(msg.message, "SUCCESS:", 8) != 0) {
|
|
|
+ if(DEBUG) {
|
|
|
printf("%s", msg.message);
|
|
|
- return -1;
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
@@ -83,9 +79,8 @@ int myco_agent_unregister_resource (int agent_message_queue_id, const char *reso
|
|
|
|
|
|
msg = myco_send_and_receive(msg, myco_get_global_message_queue(), agent_message_queue_id);
|
|
|
|
|
|
- if (strncmp(msg.message, "SUCCESS:", 8) != 0) {
|
|
|
+ if(DEBUG) {
|
|
|
printf("%s", msg.message);
|
|
|
- return -1;
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
@@ -100,15 +95,14 @@ int myco_agent_request_resource(int agent_message_queue_id, char *resource_name)
|
|
|
|
|
|
msg = myco_send_and_receive(msg, myco_get_global_message_queue(), agent_message_queue_id);
|
|
|
|
|
|
- if (strncmp(msg.message, "SUCCESS:", 8) != 0) {
|
|
|
+ if(DEBUG) {
|
|
|
printf("%s", msg.message);
|
|
|
- return -1;
|
|
|
}
|
|
|
|
|
|
resource_pointer = malloc(msg.resource_size);
|
|
|
|
|
|
if (myco_read_transactional(msg.sender_pid, msg.resource_pointer, msg.resource_size, (void *)resource_pointer, msg.resource_size) == -1) {
|
|
|
- printf("ERROR: %s\n", strerror(errno));
|
|
|
+ fprintf(stderr, "%s\n", strerror(errno));
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
@@ -126,9 +120,8 @@ int myco_agent_request_resource_list(int agent_message_queue_id) {
|
|
|
|
|
|
msg = myco_send_and_receive(msg, myco_get_global_message_queue(), agent_message_queue_id);
|
|
|
|
|
|
- if (strncmp(msg.message, "SUCCESS:", 8) != 0) {
|
|
|
+ if(DEBUG) {
|
|
|
printf("%s", msg.message);
|
|
|
- return -1;
|
|
|
}
|
|
|
|
|
|
resource_pointer = malloc(msg.resource_size);
|