src_DFR/DFR_FS.cpp File Reference

#include "../include/repository.h"
#include "../include/command.h"
#include "../include/DFR_FS.h"
#include "../include/cond_comp.h"
#include <arpa/inet.h>

Include dependency graph for DFR_FS.cpp:

Go to the source code of this file.

Functions

void * FS_req_s_body (void *sock)
 body of the threads which serve requests coming from a singular FS
void * FS_s_body (void *sock)
 body of the FS_s thread

Variables

repository_class repository
 the DFR repository of file


Function Documentation

void* FS_req_s_body ( void *  sock  ) 

body of the threads which serve requests coming from a singular FS

when a connection from a FS to the DFR is accepted, a new thread with this function as a body is created, the FS requests server. This thread will serve ALL the commands arriving from that particular FS. The socket used for the two-way communication should be open all the time, if the FS closes the socket, the DFR assumes that the FS has gone down. when the FS is sensed to be going down, this thread will automatically erase all the files registered by the FS from the repository.

you may note that a FS can connect with multiple connection to the DFR, using different ports, and creating more and more of these threads. this means that the DFR is vulnerable to a DoS (Denial of Service) attack by a FS using a lot of connection... a future extension of the DFR project should solve this problem.

Parameters:
sock | socket descriptor for communicating, passed as a (void*) for semplicity. we are assuming that sizeof(int)=sizeof(void*)

Definition at line 13 of file DFR_FS.cpp.

References repository_class::add_file(), ERR_FILE_NOT_REGISTERED, command::file_name, command::id, INT_AS_STRING_BYTES, LOG, command::max_clients, OK, command::port, receive_command(), register_file, repository_class::remove_file(), reply_command(), and unregister_file.

Referenced by FS_s_body().

void* FS_s_body ( void *  sock  ) 

body of the FS_s thread

this is the body of the FS_s, it is a typical multithreaded server for the FS commands arriving on the passed socket. when a connection arrives, this thread creates a new thread for the particular FS connection.

Parameters:
sock | socket descriptor for listening, passed as a (void*) for semplicity. we are assuming that sizeof(int) = sizeof(void*)

Definition at line 76 of file DFR_FS.cpp.

References FS_req_s_body(), LOG, and MAX_ERR_COUNT_FS.

Referenced by main().


Variable Documentation

the DFR repository of file

See also:
repository_class

Definition at line 15 of file DFR.cpp.


Generated on Sat Jun 13 21:06:30 2009 for DistributedFileRepository by  doxygen 1.5.8