Browse Source

Refined error reporting, encapsulated ipc in myco-ipc

max 8 years ago
parent
commit
990eafd626
6 changed files with 187 additions and 144 deletions
  1. 1 1
      README.md
  2. 46 66
      src/myco-agent.c
  3. 67 34
      src/myco-daemon.c
  4. 62 10
      src/myco-ipc.c
  5. 2 2
      src/myco-ipc.h
  6. 9 31
      test/mycoagent.c

+ 1 - 1
README.md

@@ -1,3 +1,3 @@
 # Mycorrhiza
 
-Studienarbeit of Max Riechelmann. A distributed resource manager written in c.
+Studienarbeit of Max Riechelmann. A distributed, transactional resource manager written in c.

+ 46 - 66
src/myco-agent.c

@@ -16,66 +16,56 @@
 #include "myco-agent.h"
 
 int myco_agent_register(const char *agent_name) {
-    int message_queue_id;
+    int agent_message_queue_id;
+    int global_message_queue_id;
     message msg;
     sprintf(msg.agent_name, "%s", agent_name);
 
-    message_queue_id = msgget(IPC_PRIVATE, PERM | IPC_CREAT);
-    if (message_queue_id < 0) {
-        printf("ERROR: Message queue could not be created. %s\n", strerror(errno));
-        return -1;
-    }
+    agent_message_queue_id = myco_create_private_message_queue();
 
-    msg.agent_message_queue_id = message_queue_id;
+    msg.agent_message_queue_id = agent_message_queue_id;
     sprintf(msg.message, "REGISTER AGENT\n");
 
-    msg = myco_send_and_receive(msg, message_queue_id);
-    if (msg.message == NULL) {
-        printf("ERROR: Transfered message is empty.");
-        return -1;
-    }
+    msg = myco_send_and_receive(msg, myco_get_global_message_queue(), agent_message_queue_id);
 
     if (strncmp(msg.message, "SUCCESS:", 8) != 0) {
         printf("%s", msg.message);
         return -1;
     }
 
-    return message_queue_id;
+    return agent_message_queue_id;
 }
 
-int myco_agent_unregister (const char *agent_name, int message_queue_id) {
+int myco_agent_unregister (const char *agent_name, int agent_message_queue_id) {
     message msg;
-    msg.agent_message_queue_id = message_queue_id;
+    msg.agent_message_queue_id = agent_message_queue_id;
     sprintf(msg.agent_name, "%s", agent_name);
     sprintf(msg.message, "UNREGISTER AGENT\n");
 
-    msg = myco_send_and_receive(msg, message_queue_id);
-    if (msg.message == NULL) {
-        printf("ERROR: Transfered message is empty.");
+    msg = myco_send_and_receive(msg, myco_get_global_message_queue(), agent_message_queue_id);
+
+    if (strncmp(msg.message, "SUCCESS:", 8) != 0) {
+        printf("%s\n", msg.message);
         return -1;
     }
 
-    if (strncmp(msg.message, "SUCCESS:", 8) != 0) {
-        printf("%s", msg.message);
+    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;
     }
 
     return 0;
 }
 
-int myco_agent_register_resource (int message_queue_id, const char *agent_name, const char *resource_name, int resource_transactional) {
+int myco_agent_register_resource (int agent_message_queue_id, const char *agent_name, const char *resource_name, int resource_transactional) {
     message msg;
-    msg.agent_message_queue_id = message_queue_id;
+    msg.agent_message_queue_id = agent_message_queue_id;
     sprintf(msg.agent_name, "%s", agent_name);
     sprintf(msg.resource_name, "%s", resource_name);
     msg.resource_transactional = resource_transactional;
     sprintf(msg.message, "REGISTER RESOURCE\n");
 
-    msg = myco_send_and_receive(msg, message_queue_id);
-    if (msg.message == NULL) {
-        printf("ERROR: Transfered message is empty.");
-        return -1;
-    }
+    msg = myco_send_and_receive(msg, myco_get_global_message_queue(), agent_message_queue_id);
 
     if (strncmp(msg.message, "SUCCESS:", 8) != 0) {
         printf("%s", msg.message);
@@ -85,17 +75,13 @@ int myco_agent_register_resource (int message_queue_id, const char *agent_name,
     return 0;
 }
 
-int myco_agent_unregister_resource (int message_queue_id, const char *resource_name) {
+int myco_agent_unregister_resource (int agent_message_queue_id, const char *resource_name) {
     message msg;
-    msg.agent_message_queue_id = message_queue_id;
+    msg.agent_message_queue_id = agent_message_queue_id;
     sprintf(msg.resource_name, "%s", resource_name);
     sprintf(msg.message, "UNREGISTER RESOURCE\n");
 
-    msg = myco_send_and_receive(msg, message_queue_id);
-    if (msg.message == NULL) {
-        printf("ERROR: Transfered message is empty.");
-        return -1;
-    }
+    msg = myco_send_and_receive(msg, myco_get_global_message_queue(), agent_message_queue_id);
 
     if (strncmp(msg.message, "SUCCESS:", 8) != 0) {
         printf("%s", msg.message);
@@ -105,40 +91,40 @@ int myco_agent_unregister_resource (int message_queue_id, const char *resource_n
     return 0;
 }
 
-int myco_agent_request_resource(int message_queue_id, char *resource_name) {
+int myco_agent_request_resource(int agent_message_queue_id, char *resource_name) {
+    char *resource_pointer;
     message msg;
-    msg.agent_message_queue_id = message_queue_id;
+    msg.agent_message_queue_id = agent_message_queue_id;
     sprintf(msg.resource_name, "%s", resource_name);
     sprintf(msg.message, "REQUEST RESOURCE\n");
 
-    msg = myco_send_and_receive(msg, message_queue_id);
-    if (msg.message == NULL) {
-        printf("ERROR: Transfered message is empty.");
-        return -1;
-    }
+    msg = myco_send_and_receive(msg, myco_get_global_message_queue(), agent_message_queue_id);
 
     if (strncmp(msg.message, "SUCCESS:", 8) != 0) {
         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));
+        return -1;
+    }
+
     return 0;
 }
 
-int myco_agent_request_resource_list(int message_queue_id) {
+int myco_agent_request_resource_list(int agent_message_queue_id) {
     char *resource_pointer;
     char *split;
 
     message msg;
-    msg.agent_message_queue_id = message_queue_id;
+    msg.agent_message_queue_id = agent_message_queue_id;
     sprintf(msg.message, "REQUEST LIST\n");
     msg.resource_size = 0;
 
-    msg = myco_send_and_receive(msg, message_queue_id);
-    if (msg.message == NULL) {
-        printf("ERROR: Transfered message is empty.");
-        return -1;
-    }
+    msg = myco_send_and_receive(msg, myco_get_global_message_queue(), agent_message_queue_id);
 
     if (strncmp(msg.message, "SUCCESS:", 8) != 0) {
         printf("%s", msg.message);
@@ -152,6 +138,9 @@ int myco_agent_request_resource_list(int message_queue_id) {
         return -1;
     }
 
+    sprintf(msg.message, "RESOURCE GRANTED\n");
+    myco_send(agent_message_queue_id, msg);
+
     printf("%s\n", resource_pointer);
     /*
     split = strtok(resource_pointer, ";");
@@ -165,44 +154,35 @@ int myco_agent_request_resource_list(int message_queue_id) {
     return 0;
 }
 
-int myco_agent_request_remote_resource(int message_queue_id, char *resource_name) {
+int myco_agent_request_remote_resource(int agent_message_queue_id, char *resource_name) {
     message msg;
-    msg.agent_message_queue_id = message_queue_id;
+    msg.agent_message_queue_id = agent_message_queue_id;
     sprintf(msg.resource_name, "%s", resource_name);
     sprintf(msg.message, "REQUEST REMOTE RESOURCE\n");
 
-    msg = myco_send_and_receive(msg, message_queue_id);
-    if (msg.message == NULL) {
-        return -1;
-    }
+    msg = myco_send_and_receive(msg, myco_get_global_message_queue(), agent_message_queue_id);
 
     return 0;
 }
 
-int myco_agent_write_remote_resource(int message_queue_id, char *resource_name) {
+int myco_agent_write_remote_resource(int agent_message_queue_id, char *resource_name) {
     message msg;
-    msg.agent_message_queue_id = message_queue_id;
+    msg.agent_message_queue_id = agent_message_queue_id;
     sprintf(msg.resource_name, "%s", resource_name);
     sprintf(msg.message, "WRITE REMOTE RESOURCE\n");
 
-    msg = myco_send_and_receive(msg, message_queue_id);
-    if (msg.message == NULL) {
-        return -1;
-    }
+    msg = myco_send_and_receive(msg, myco_get_global_message_queue(), agent_message_queue_id);
 
     return 0;
 }
 
-int myco_agent_read_remote_resource(int message_queue_id, char *resource_name) {
+int myco_agent_read_remote_resource(int agent_message_queue_id, char *resource_name) {
     message msg;
-    msg.agent_message_queue_id = message_queue_id;
+    msg.agent_message_queue_id = agent_message_queue_id;
     sprintf(msg.resource_name, "%s", resource_name);
     sprintf(msg.message, "READ REMOTE RESOURCE\n");
 
-    msg = myco_send_and_receive(msg, message_queue_id);
-    if (msg.message == NULL) {
-        return -1;
-    }
+    msg = myco_send_and_receive(msg, myco_get_global_message_queue(), agent_message_queue_id);
 
     return 0;
 }

+ 67 - 34
src/myco-daemon.c

@@ -35,7 +35,8 @@ int myco_daemon_register_agent(message msg) {
 
     if (myco_daemon_find_agent(msg.agent_name) != NULL) {
         sprintf(msg.message, "ERROR: agent %s already exists\n", msg.agent_name);
-        msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+        myco_send(msg.agent_message_queue_id, msg);
+
         return -1;
     }
 
@@ -58,7 +59,8 @@ int myco_daemon_register_agent(message msg) {
     }
 
     sprintf(msg.message, "SUCCESS: agent %s registered\n", msg.agent_name);
-    msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+    myco_send(msg.agent_message_queue_id, msg);
+
     return 0;
 
 }
@@ -70,7 +72,8 @@ int myco_daemon_unregister_agent(message msg) {
 
     if (current_agent == NULL) {
         sprintf(msg.message, "ERROR: agent %s could not be unregistered\n", msg.agent_name);
-        msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+        myco_send(msg.agent_message_queue_id, msg);
+
         return -1;
     }
 
@@ -80,7 +83,8 @@ int myco_daemon_unregister_agent(message msg) {
         current_agent->next->prev = current_agent->prev;
         free(current_agent);
         sprintf(msg.message, "SUCCESS: agent %s unregistered\n", msg.agent_name);
-        msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+        myco_send(msg.agent_message_queue_id, msg);
+
         return 0;
     }
 
@@ -90,16 +94,18 @@ int myco_daemon_unregister_agent(message msg) {
         current_agent->next->prev = NULL;
         free(current_agent);
         sprintf(msg.message, "SUCCESS: agent %s unregistered\n", msg.agent_name);
-        msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+        myco_send(msg.agent_message_queue_id, msg);
+
         return 0;
     }
-    
+
     // Last element
     if (current_agent->next == NULL && current_agent->prev != NULL) {
         current_agent->prev->next = NULL;
         free(current_agent);
         sprintf(msg.message, "SUCCESS: agent %s unregistered\n", msg.agent_name);
-        msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+        myco_send(msg.agent_message_queue_id, msg);
+
         return 0;
     }
 
@@ -108,12 +114,14 @@ int myco_daemon_unregister_agent(message msg) {
         first_agent = NULL;
         free(current_agent);
         sprintf(msg.message, "SUCCESS: agent %s unregistered\n", msg.agent_name);
-        msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+        myco_send(msg.agent_message_queue_id, msg);
+
         return 0;
     }
 
     sprintf(msg.message, "ERROR: agent %s could not be unregistered - data structure seems to be damaged!\n", msg.agent_name);
-    msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+    myco_send(msg.agent_message_queue_id, msg);
+
     return -1;
 }
 
@@ -144,9 +152,17 @@ myco_resource *myco_daemon_find_resource(const char *resource_name) {
 int myco_daemon_register_resource(message msg) {
     myco_resource *current_resource;
 
+    if (myco_daemon_find_agent(msg.agent_name) == NULL) {
+        sprintf(msg.message, "ERROR: agent %s does not exist\n", msg.agent_name);
+        myco_send(msg.agent_message_queue_id, msg);
+
+        return -1;
+    }
+
     if (myco_daemon_find_resource(msg.resource_name) != NULL) {
         sprintf(msg.message, "ERROR: resource %s already exists\n", msg.resource_name);
-        msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+        myco_send(msg.agent_message_queue_id, msg);
+
         return -1;
     }
 
@@ -173,7 +189,8 @@ int myco_daemon_register_resource(message msg) {
     }
 
     sprintf(msg.message, "SUCCESS: resource %s registered\n", msg.resource_name);
-    msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+    myco_send(msg.agent_message_queue_id, msg);
+
     return 0;
 }
 
@@ -184,7 +201,8 @@ int myco_daemon_unregister_resource(message msg) {
 
     if (current_resource == NULL) {
         sprintf(msg.message, "ERROR: resource %s could not be unregistered\n", msg.resource_name);
-        msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+        myco_send(msg.agent_message_queue_id, msg);
+
         return -1;
     }
 
@@ -194,7 +212,8 @@ int myco_daemon_unregister_resource(message msg) {
         current_resource->next->prev = current_resource->prev;
         free(current_resource);
         sprintf(msg.message, "SUCCESS: resource %s unregistered\n", msg.resource_name);
-        msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+        myco_send(msg.agent_message_queue_id, msg);
+
         return 0;
     }
 
@@ -204,16 +223,18 @@ int myco_daemon_unregister_resource(message msg) {
         current_resource->next->prev = NULL;
         free(current_resource);
         sprintf(msg.message, "SUCCESS: resource %s unregistered\n", msg.resource_name);
-        msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+        myco_send(msg.agent_message_queue_id, msg);
+
         return 0;
     }
-    
+
     // Last element
     if (current_resource->next == NULL && current_resource->prev != NULL) {
         current_resource->prev->next = NULL;
         free(current_resource);
         sprintf(msg.message, "SUCCESS: resource %s unregistered\n", msg.resource_name);
-        msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+        myco_send(msg.agent_message_queue_id, msg);
+
         return 0;
     }
 
@@ -222,18 +243,21 @@ int myco_daemon_unregister_resource(message msg) {
         first_resource = NULL;
         free(current_resource);
         sprintf(msg.message, "SUCCESS: resource %s unregistered\n", msg.resource_name);
-        msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+        myco_send(msg.agent_message_queue_id, msg);
+
         return 0;
     }
 
-    sprintf(msg.message, "ERROR: resource %s could not be unregistered - data structure seems to be damaged!\n", msg.resource_name);
-    msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+    sprintf(msg.message, "FATAL ERROR: resource %s could not be unregistered - data structure seems to be damaged!\n", msg.resource_name);
+    myco_send(msg.agent_message_queue_id, msg);
+
     return -1;
 }
 
 int myco_daemon_request_resource(message msg) {
     sprintf(msg.message, "SUCCESS: resource granted\n");
-    msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+    myco_send(msg.agent_message_queue_id, msg);
+
     return 0;
 }
 
@@ -267,53 +291,57 @@ int myco_daemon_request_list(message msg, pid_t pid) {
         current_resource = current_resource->next;
     }
 
-    printf("%s\n", resource_pointer);
-
     msg.sender_pid = pid;
     msg.resource_size = resource_size;
     msg.resource_pointer = (void *)resource_pointer;
     sprintf(msg.message, "SUCCESS: sending resource list\n");
-    msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+    myco_send(msg.agent_message_queue_id, msg);
 
-    free(resource_pointer);
-    // free when done.
+    msg = myco_receive(msg.agent_message_queue_id);
+    if (strcmp(msg.message, "RESOURCE GRANTED\n") == 0) {
+        free(resource_pointer);
+    } else {
+        fprintf(stderr, "ERROR: myco_daemon_request_list: %s\n", strerror(errno));
+        return -1;
+    }
 
     return 0;
 }
 
 int myco_daemon_request_remote_resource(message msg) {
     sprintf(msg.message, "SUCCESS: remote resource shared\n");
-    msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+    myco_send(msg.agent_message_queue_id, msg);
     return 0;
 }
 
 int myco_daemon_write_remote_resource(message msg) {
     sprintf(msg.message, "SUCCESS: written to remote resource %s\n", msg.resource_name);
-    msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+    myco_send(msg.agent_message_queue_id, msg);
     return 0;
 }
 
 int myco_daemon_read_remote_resource(message msg) {
     sprintf(msg.message, "SUCCESS: read from remote resource %s\n", msg.resource_name);
-    msgsnd(msg.agent_message_queue_id, &msg, TOTAL_LENGTH, 0);
+    myco_send(msg.agent_message_queue_id, msg);
     return 0;
 }
 
 int myco_daemon_start(pid) {
-    int message_queue_id;
+    int daemon_message_queue_id;
     message msg;
 
     // Create message queue
-    message_queue_id = msgget(KEY, PERM | IPC_CREAT);
-    if (message_queue_id < 0) {
-        printf("ERROR: Message queue could not be created. %s\n", strerror(errno));
+    daemon_message_queue_id = myco_create_global_message_queue();
+    if (daemon_message_queue_id < 0) {
+        fprintf(stderr, "ERROR: Message queue could not be created. %s\n", strerror(errno));
         return -1;
     }
 
     // Receive messages
     while (1) {
-        if (msgrcv(message_queue_id, &msg, TOTAL_LENGTH, 0, 0) == -1) {
-            printf("ERROR: No message could be received. %s\n", strerror(errno));
+        msg = myco_receive(daemon_message_queue_id);
+        if (msg.message == NULL) {
+            fprintf(stderr, "FATAL ERROR: No message could be received. %s\n", strerror(errno));
             return -1;
         } else {
             if (strcmp(msg.message, "REGISTER AGENT\n") == 0) {
@@ -345,6 +373,11 @@ int myco_daemon_start(pid) {
             }
         } 
     }
+    
+    if (myco_remove_message_queue(daemon_message_queue_id) == -1) {
+        fprintf(stderr, "FATAL ERROR: could not remove message queue %d\n", daemon_message_queue_id);
+        return -1;
+    }
 
 
     return EXIT_SUCCESS;

+ 62 - 10
src/myco-ipc.c

@@ -16,13 +16,63 @@
 
 #include "myco-ipc.h"
 
-int myco_send(message msg) {
+int myco_error(char *error_message, int message_queue_id) {
+    fprintf(stderr, "ERROR: ");
+    fprintf(stderr, error_message);
+    fprintf(stderr, "=> %s\n", strerror(errno));
+    myco_remove_message_queue(message_queue_id);
+    exit(1);
+}
+
+int myco_create_private_message_queue() {
+    int message_queue_id;
+
+    message_queue_id = msgget(IPC_PRIVATE, PERM | IPC_CREAT);
+
+    if (message_queue_id == -1) {
+        fprintf(stderr, "ERROR: myco_create_private_message_queue() => %s\n", strerror(errno));
+        error(1);
+    }
+
+    return message_queue_id;
+}
+
+int myco_create_global_message_queue() {
+    int message_queue_id;
+
+    message_queue_id = msgget(KEY, PERM | IPC_CREAT);
+    if (message_queue_id == -1) {
+        fprintf(stderr, "ERROR: myco_create_global_message_queue() => %s\n", strerror(errno));
+        error(1);
+    }
+
+    return message_queue_id;
+}
+
+int myco_get_global_message_queue() {
     int message_queue_id;
+
     message_queue_id = msgget(KEY, 0);
+    if (message_queue_id == -1) {
+        fprintf(stderr, "ERROR: myco_get_global_message_queue() => %s\n", strerror(errno));
+        error(1);
+    }
+
+    return message_queue_id;
+}
+
+int myco_remove_message_queue(int message_queue_id) {
+    if (msgctl(message_queue_id, IPC_RMID, NULL) == -1) {
+        fprintf(stderr, "ERROR: myco_remove_message_queue() %d => %s\n", message_queue_id, strerror(errno));
+        exit(1);
+    }
+    
+    return 0;
+}
 
+int myco_send(int message_queue_id, message msg) {
     if (msgsnd(message_queue_id, &msg, TOTAL_LENGTH, 0) < 0) {
-        printf("ERROR: Could not send message. %s\n", strerror(errno));
-        return -1;
+        myco_error("myco_send()", message_queue_id);
     }
 
     return 0;
@@ -32,18 +82,20 @@ message myco_receive(int message_queue_id) {
     message msg;
 
     if (msgrcv(message_queue_id, &msg, TOTAL_LENGTH, 0, 0) == -1) {
-        printf("ERROR: No message could be received. %s\n", strerror(errno));
-        return msg;
+        myco_error("myco_receive()", message_queue_id);
+    }
+
+    if (msg.message == NULL) {
+        myco_error("myco_receive()", message_queue_id);
     }
 
     return msg;
 }
 
-message myco_send_and_receive(message msg, int message_queue_id) {
-    if (myco_send(msg) == -1) {
-        return msg;
-    }
-    msg = myco_receive(message_queue_id);
+message myco_send_and_receive(message msg, int send_message_queue_id, int receive_message_queue_id) {
+    myco_send(send_message_queue_id, msg);
+
+    msg = myco_receive(receive_message_queue_id);
 
     return msg;
 }

+ 2 - 2
src/myco-ipc.h

@@ -48,11 +48,11 @@ typedef struct {
     pid_t sender_pid;
 } message;
 
-int myco_send(message msg);
+int myco_send(int message_queue_id, message msg);
 
 message myco_receive(int message_queue_id);
 
-message myco_send_and_receive(message msg, int message_queue_id);
+message myco_send_and_receive(message msg, int send_message_queue_id, int receive_message_queue_id);
 
 int myco_read_transactional(pid_t source_pid, void *source_pointer, int source_length, void *target_pointer, int target_length);
 

+ 9 - 31
test/mycoagent.c

@@ -7,39 +7,17 @@
 int main() {
     int message_queue_id;
 
+    if ((message_queue_id = myco_agent_register("MYAGENT")) == -1) {
+        return EXIT_FAILURE;
+    }
 
-    message_queue_id = myco_agent_register("MYAGENT");
-    message_queue_id = myco_agent_register_resource(message_queue_id, "MYAGENT", "MYTRANSACTIONALRESOURCE", RESOURCE_TRANSACTIONAL);
-    message_queue_id = myco_agent_register_resource(message_queue_id, "MYAGENT", "MYNOTTRANSACTIONALRESOURCE", RESOURCE_NOT_TRANSACTIONAL);
-    message_queue_id = myco_agent_register_resource(message_queue_id, "MYAGENT", "MYTRANSACTIONALRESOURCE2", RESOURCE_TRANSACTIONAL);
-    message_queue_id = myco_agent_register_resource(message_queue_id, "MYAGENT", "MYTRANSACTIONALRESOURCE3", RESOURCE_TRANSACTIONAL);
+    myco_agent_register_resource(message_queue_id, "MYAGENT", "MYTRANSACTIONALRESOURCE", RESOURCE_TRANSACTIONAL);
+    myco_agent_register_resource(message_queue_id, "MYAGENT", "MYTRANSACTIONALRESOURCE", RESOURCE_TRANSACTIONAL);
+    myco_agent_register_resource(message_queue_id, "MYAGENT2", "MYTRANSACTIONALRESOURCE2", RESOURCE_TRANSACTIONAL);
+    myco_agent_request_resource_list(message_queue_id);
+    myco_agent_unregister_resource(message_queue_id, "MYTRANSACTIONALRESOURCE");
+    myco_agent_unregister("MYAGENT", message_queue_id);
 
-    message_queue_id = myco_agent_request_resource_list(message_queue_id);
-
-    message_queue_id = myco_agent_unregister_resource(message_queue_id, "MYTRANSACTIONALRESOURCE");
-    message_queue_id = myco_agent_unregister_resource(message_queue_id, "MYTRANSACTIONALRESOURCE2");
-    message_queue_id = myco_agent_unregister_resource(message_queue_id, "MYTRANSACTIONALRESOURCE3");
-    message_queue_id = myco_agent_unregister_resource(message_queue_id, "MYNOTTRANSACTIONALRESOURCE");
-    message_queue_id = myco_agent_unregister("MYAGENT", message_queue_id);
-
-
-/*
-    message_queue_id = myco_agent_request_resource_list(message_queue_id);
-    message_queue_id = myco_agent_register_resource(message_queue_id, "MYAGENT", "MYTRANSACTIONALRESOURCE", RESOURCE_TRANSACTIONAL);
-    message_queue_id = myco_agent_register_resource(message_queue_id, "MYAGENT", "MYTRANSACTIONALRESOURCE", RESOURCE_TRANSACTIONAL);
-    message_queue_id = myco_agent_request_resource(message_queue_id, "MYTRANSACTIONALRESOURCE");
-    message_queue_id = myco_agent_request_resource_list(message_queue_id);
-    message_queue_id = myco_agent_request_remote_resource(message_queue_id, "MYTRANSACTIONALRESOURCE");
-    message_queue_id = myco_agent_unregister_resource(message_queue_id, "MYTRANSACTIONALRESOURCE");
-    message_queue_id = myco_agent_request_resource_list(message_queue_id);
-    message_queue_id = myco_agent_write_remote_resource(message_queue_id, "MYNOTTRANSACTIONALRESOURCE");
-    message_queue_id = myco_agent_read_remote_resource(message_queue_id, "MYNOTTRANSACTIONALRESOURCE");
-    message_queue_id = myco_agent_unregister("MYAGENT2", message_queue_id);
-    message_queue_id = myco_agent_unregister_resource(message_queue_id, "MYNOTTRANSACTIONALRESOURCE");
-    message_queue_id = myco_agent_request_resource_list(message_queue_id);
-    message_queue_id = myco_agent_unregister("MYAGENT", message_queue_id);
-    message_queue_id = myco_agent_unregister("MYAGENT2", message_queue_id);
-*/
 
     return EXIT_SUCCESS;
 }