Changes

Jump to navigation Jump to search
17 bytes added ,  12:55, 28 December 2018
m
Spelling and grammar fixes
Line 1: Line 1:  
= Masters and slaves =
 
= Masters and slaves =
# A file may be referred by several file descriptors. The descriptors may belong to a single process or to several processes.
+
# A file may be referred to by several file descriptors. The descriptors may belong to a single process or to several processes.
# Group of descriptors referring to the same file is called shared. One of the descriptors is named master, others are slaves.
+
# A group of descriptors referring to the same file is called shared. One of the descriptors is named master, others are slaves.
# Every descriptor is discribed via struct fdinfo_list_entry (fle).
+
# Every descriptor is described via struct fdinfo_list_entry (fle).
# One process opens a master fle of a file, while other processes, sharing the file, obtain it using scm_rights. See send_fds() and receive_fds() for the details.
+
# One process opens a master fle of a file, while other processes, sharing the file, obtain it using scm_rights. See send_fds() and receive_fds() for details.
   −
= Per-process files restore =
+
= Per-process file restore =
Every file types is described via structure file_desc. We sequentially call file_desc::ops::open(struct file_desc *d, int *new_fd) method for every master file of a process until all masters are restored. The open methods may return three values:
+
Every file type is described via structure file_desc. We sequentially call file_desc::ops::open(struct file_desc *d, int *new_fd) method for every master file of a process until all masters are restored. The open methods may return three values:
 
*  0  -- restore of the master file is successefuly finished;
 
*  0  -- restore of the master file is successefuly finished;
 
*  1  -- restore is in progress or it can't be started yet, because of it depends on another files, so the method should be called once again;
 
*  1  -- restore is in progress or it can't be started yet, because of it depends on another files, so the method should be called once again;
 
* -1 -- restore failed.
 
* -1 -- restore failed.
   −
Right after a file is open at first time, the open method must return fd value in new_fd argument. This allows the common code to send this master to other processes to reopen the master as a slave as soon as possible. The same time, returning of not-negative new_fd does not mean, that the master is restored. The open() callback may return not-negative new_fd and "1" as return value at the same time.
+
Right after a file is opened for the first time, the open method must return the fd value in the new_fd argument. This allows the common code to send this master to other processes to reopen the master as a slave as soon as possible. At the same time, returning a non-negative new_fd does not mean that the master is restored. The open() callback may return a non-negative new_fd and "1" as return value at the same time.
    
Example. Restore of connected unix socket by open() method.
 
Example. Restore of connected unix socket by open() method.
4

edits

Navigation menu