Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Current state. See changelog, sorry, I'm out of time
[simgrid.git] / src / gras / Transport / transport_plugin_file.c
index 3fc5f57..11f1a29 100644 (file)
@@ -9,14 +9,16 @@
    under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <errno.h>
+#include <sys/time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <unistd.h>
 
-#include "gras_private.h"
 #include "transport_private.h"
 
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(trp_file,transport);
+GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(trp_file,transport,
+       "Pseudo-transport to write to/read from a file");
 
 /***
  *** Prototypes 
@@ -52,17 +54,13 @@ typedef struct {
 gras_error_t
 gras_trp_file_setup(gras_trp_plugin_t *plug) {
 
-  gras_trp_file_plug_data_t *file = malloc(sizeof(gras_trp_file_plug_data_t));
-  if (!file)
-    RAISE_MALLOC;
+  gras_trp_file_plug_data_t *file = gras_new(gras_trp_file_plug_data_t,1);
 
   FD_ZERO(&(file->incoming_socks));
 
   plug->socket_close = gras_trp_file_close;
-
   plug->chunk_send   = gras_trp_file_chunk_send;
   plug->chunk_recv   = gras_trp_file_chunk_recv;
-
   plug->data         = (void*)file;
 
   return no_error;
@@ -84,7 +82,7 @@ gras_socket_client_from_file(const char*path,
   gras_assert0(gras_if_RL(),
               "Cannot use file as socket in the simulator");
 
-  TRY(gras_trp_socket_new(0,dst));
+  gras_trp_socket_new(0,dst);
 
   TRY(gras_trp_plugin_get_by_name("file",&trp));
   (*dst)->plugin=trp;
@@ -127,7 +125,7 @@ gras_socket_server_from_file(const char*path,
   gras_assert0(gras_if_RL(),
               "Cannot use file as socket in the simulator");
 
-  TRY(gras_trp_socket_new(1,dst));
+  gras_trp_socket_new(1,dst);
 
   TRY(gras_trp_plugin_get_by_name("file",&trp));
   (*dst)->plugin=trp;