include/DFR_CL.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define MAX_ERR_COUNT_CL   3
 maximum number of generic errors before exiting or terminating the CL thread

Functions

void serve_start_file_transfer (int req_sock, string file_name, string CL_address, list< string > *obtained_files, bool *error)
 support function for command start_file_transfer
void serve_end_file_transfer (int req_sock, string file_name, string CL_address, list< string > *obtained_files, bool *error)
 support function for command end_file_transfer
void serve_reg_notification (int req_sock, string file_name, string CL_address, list< string > *obtained_files, bool *error)
 support function for command reg_notification
void * CL_req_s_body (void *sock)
 body of the threads which serve requests coming from a singular CL
void * CL_s_body (void *sock)
 body of the CL_s thread


Define Documentation

#define MAX_ERR_COUNT_CL   3

maximum number of generic errors before exiting or terminating the CL thread

Definition at line 7 of file DFR_CL.h.

Referenced by CL_s_body().


Function Documentation

void* CL_req_s_body ( void *  sock  ) 

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

when a connection from a CL to the DFR is accepted, a new thread with this function as a body is created, the CL requests server. This thread will serve ALL the commands arriving from that particular CL, sequentially. The socket used for the two-way communication should be open all the time, if the CL closes the socket, the DFR assumes that the CL has gone down or finished using the Distributed Repository, this means that when this happens, the CL SHOULD NOT be transferring files from a FS. when the CL is sensed to be going down, this thread will automatically release all the files that the CL had obtained from the DFR.

you may note that a CL 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 CL using a lot of connection... a future extension of the DFR project should solve this problem.

the choice of using a sequential request server for requests coming from the same CL was preferred because the DFR must have a way to identify clients in the repository:

  • using IP address is too restrictive
  • using ports means that a client cannot connect different times to send commands, the port needs to remain the same, and so the socket should be the same
  • the last option is to use sockets as in the FS_req_s for FSs. this is our choice, but this means that to each client is associated just one socket and not more than one DFR thread should be using it to communicate with the client, and requests from the same client are served sequentially

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

Definition at line 99 of file DFR_CL.cpp.

References end_file_transfer, command::file_name, command::id, INT_AS_STRING_BYTES, LOG, receive_command(), reg_notification, repository_class::release_file(), serve_end_file_transfer(), serve_reg_notification(), serve_start_file_transfer(), and start_file_transfer.

Referenced by CL_s_body().

void* CL_s_body ( void *  sock  ) 

body of the CL_s thread

this is the body of the CL_s, there is just one thread with this body running at any time, it accepts connections from clients. each connection corresponds to a client, and it must stay up until the client has finished his work. for each connection, this thread creates a new thread for that particular CL connection.

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

Definition at line 154 of file DFR_CL.cpp.

References CL_req_s_body(), LOG, and MAX_ERR_COUNT_CL.

Referenced by main().

void serve_end_file_transfer ( int  req_sock,
string  file_name,
string  CL_address,
list< string > *  obtained_files,
bool *  error 
)

support function for command end_file_transfer

this function executes all operation necessary for the end_file_transfer command, it must be called when an end_file_transfer command arrives

Parameters:
req_sock | socket to speak with the CL
file_name | file the CL wants to transfer
CL_address | address and port of the CL
obtained_files | pointer to the list the calling thread is using to keep track of client operations
error | pointer to the boolean variable the calling thread is using to keep track of errors

Definition at line 45 of file DFR_CL.cpp.

References ERR_NO_TRANSFER, LOG, OK, repository_class::release_file(), and reply_command().

Referenced by CL_req_s_body().

void serve_reg_notification ( int  req_sock,
string  file_name,
string  CL_address,
list< string > *  obtained_files,
bool *  error 
)

support function for command reg_notification

this function executes all operation necessary for the reg_notification command, it must be called when an reg_notification command arrives

this function uses the serve_start_file_transfer() function when the client is notified and replies with an OK response message

Parameters:
req_sock | socket to speak with the CL
file_name | file the CL wants to transfer
CL_address | address and port of the CL
obtained_files | pointer to the list the calling thread is using to keep track of client operations
error | pointer to the boolean variable the calling thread is using to keep track of errors
See also:
serve_start_file_transfer()

Definition at line 72 of file DFR_CL.cpp.

References ERR_NO_NOTIFICATION, LOG, notify, OK, reply_command(), send_command(), serve_start_file_transfer(), and repository_class::wait_file().

Referenced by CL_req_s_body().

void serve_start_file_transfer ( int  req_sock,
string  file_name,
string  CL_address,
list< string > *  obtained_files,
bool *  error 
)

support function for command start_file_transfer

this function executes all operation necessary for the start_file_transfer command, it can be called when a start_file_transfer command arrives, or it can be called if the DFR sent a notify command to the CL and a response was received with the OK state

Parameters:
req_sock | socket to speak with the CL
file_name | file the CL wants to transfer
CL_address | address and port of the CL
obtained_files | pointer to the list the calling thread is using to keep track of client operations
error | pointer to the boolean variable the calling thread is using to keep track of errors

Definition at line 13 of file DFR_CL.cpp.

References ERR_FILE_NOT_EXISTS, ERR_TOO_MANY_CLIENTS, INT_AS_STRING_BYTES, LOG, repository_class::obtain_file(), OK, and reply_command().

Referenced by CL_req_s_body(), and serve_reg_notification().


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