Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

renderfarmfsclient.h

Go to the documentation of this file.
00001 #ifndef RENDERFARMFSCLIENT_H
00002 #define RENDERFARMFSCLIENT_H
00003 
00004 #include "mutex.inc"
00005 #include "renderfarmclient.inc"
00006 #include "renderfarmfsclient.inc"
00007 
00008 
00009 // This should override the stdio commands and inderect operations on any file
00010 // starting with RENDERFARM_FS_PREFIX to the network.
00011 
00012 // The server runs on the master node.
00013 // The client runs on the client.
00014 
00015 // The traffic shares the same socket as the rest of the rendering traffic
00016 // so the server and client command loops have to give control to the 
00017 // VFS objects when they get a VFS command.
00018 
00019 // Only one RenderFarmClient can exist per image because the stdio operations 
00020 // don't allow pointers to local storage.  Fortunately only one
00021 // RenderFarmClient exists per image by default.  The RenderFarmClient just needs
00022 // to wait until it's forked before creating RenderFarmFSClient.
00023 // The RenderFarmClient is a mutual 
00024 // exclusion lock and table of file descriptors.  
00025 // It searches through the table to see if the file descriptor is virtual.
00026 // Then it translates a single stdio call at a time to and from 
00027 // network commands, complete with the original parameters and return values.
00028 
00029 // The RenderFarmFSServer takes one command from the network at a time and passes 
00030 // it directly to the stdio call.  If call has a buffer, the buffer is
00031 // created by the RenderFarmFSServer and streamed over the network.  
00032 // The return values are passed untouched back through the network.
00033 
00034 // FILE* and int on RenderFarmClient are meaningless.
00035 // They can't be dereferenced.
00036 // Unfortunately, nothing else in Cinelerra can override stdio now.
00037 
00038 // All the stdio functions are transferred in endian independant ways except
00039 // stat, stat64.
00040 
00041 extern RenderFarmFSClient *renderfarm_fs_global;
00042 
00043 class RenderFarmFSClient
00044 {
00045 public:
00046         RenderFarmFSClient(RenderFarmClientThread *client);
00047         ~RenderFarmFSClient();
00048 
00049         void initialize();
00050 
00051 // Called by the overloaded C library functions.
00052 // There may be more.
00053         FILE* fopen(const char *path, const char *mode);
00054         int fclose(FILE *file);
00055         int remove (__const char *__filename);
00056         int rename (__const char *__old, __const char *__new);
00057         int fgetc (FILE *__stream);
00058         int fputc (int __c, FILE *__stream);
00059         size_t fread (void *__restrict __ptr, size_t __size,
00060                          size_t __n, FILE *__restrict __stream);
00061         size_t fwrite (__const void *__restrict __ptr, size_t __size,
00062                           size_t __n, FILE *__restrict __s);
00063         int fseek (FILE *__stream, int64_t __off, int __whence);
00064         int64_t ftell (FILE *__stream);
00065         int stat64 (__const char *__restrict __file,
00066                            struct stat64 *__restrict __buf);
00067         int stat (__const char *__restrict __file,
00068                          struct stat *__restrict __buf);
00069         char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream);
00070         int fileno(FILE *file);
00071         int fscanf(FILE *__restrict stream, const char *__restrict format, va_list ap);
00072 
00073 // Locking order:
00074 // 1) RenderFarmFSClient
00075 // 2) RenderFarmClient
00076         void lock();
00077         void unlock();
00078         int is_open(FILE *ptr);
00079 // The 64 bit argument is ignored in 64 bit architectures
00080         void set_open(FILE *ptr, int64_t pointer);
00081         void unset_open(FILE *ptr, int64_t pointer);
00082 // Used in place of Units::ptr_to_int64 in case the pointer is only 32 bits.
00083         int64_t get_64(FILE *ptr);
00084 
00085         Mutex *mutex_lock;
00086         ArrayList<FILE*> files;
00087 // In 32 bit mode, this stores the 64 bit equivalents of the file handles.
00088 // The 64 bit values are ignored in 64 bit architectures
00089         ArrayList<int64_t> pointers;
00090         RenderFarmClientThread *client;
00091 };
00092 
00093 
00094 
00095 
00096 
00097 #endif

Generated on Sun Jan 8 13:39:00 2006 for Cinelerra-svn by  doxygen 1.4.4