diff options
Diffstat (limited to 'docs/html/xbc12.htm')
-rwxr-xr-x | docs/html/xbc12.htm | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/docs/html/xbc12.htm b/docs/html/xbc12.htm new file mode 100755 index 0000000..f9fe114 --- /dev/null +++ b/docs/html/xbc12.htm @@ -0,0 +1,72 @@ +<!DOCTYPE HTML PUBLIC> +<HTML> +<TITLE>Xbase DBMS Chapter 8</TITLE> +<BODY BGCOLOR=#FFFFFF> +<H1><p align="center">Record and File Locking</p></H1> +<p align="center">Chapter Updated 11/29/22</p><hr> + +<h3>Locking Overview</h3> + +Xbase64 supports multi-user processing through file and record locks. +Record locking restricts multiple cooperating programs from simultaneously +accessing the same data and corrupting it. Without record and file locking +in a multi-user environment, simultaneous access to the data and index files +can cause the files to become inaccurate and unusable.<br><br> + +Automatic record locking is on by default in the Xbase64 library. To disable it, +use method xbXBase::DisableDefaultAutoLock() and to enable it, use method xbXBase::EnableDefaultAutoLock(). + +Locking can also be enabled / disabled at the table level with with xbDbf::SetAutoLock(). + + +<br><br> +The current Xbase64 record locking logic is modeled after DBase (tm) V7 locking. +<br><br> + +The locking methods return either XB_LOCK_FAILED or XB_NO_ERROR. If they return +XB_LOCK_FAILED the actual reason can be found in the global variable +<em>errno</em> or function <em>perror()</em> can be executed to view the +results. +<br><br> + +The errno field may contain one of the following values if the lock was not +successful.<br><br> +<TABLE BORDER> +<TR VALIGN="BASELINE"> +<TR><TH ALIGN="LEFT">Error Code<TD>Description +<TR><TH ALIGN="LEFT">EBADF<TD>Invalid file descriptor +<TR><TH ALIGN="LEFT">EINVAL<TD>Invalid lock information or file does not support locks +<TR><TH ALIGN="LEFT">EACCESS<BR>EAGAIN<TD>Lock can not be set because it is blocked by an existing lock on the file. +<TR><TH ALIGN="LEFT">ENOLCK<TD>The system is out of lock resources, too many file locks in place. +<TR><TH ALIGN="LEFT">EDEADLK<TD>Deadlock condition +<TR><TH ALIGN="LEFT">EINTR<TD>Process was interrupted by a signal while it was waiting +</TABLE> +<br><br> + +<h3>Linux/Windows File Locking Compatibility Issue</h3> + +There is a compatibility locking issue to be aware of. Windows environments allow for the exclusive +opening of file handles and Linux/Unix platforms do not. If you are writing an application that will be +using a tool like Dbase on a Windows machine, accessing a file on a Linux/Samba configure machine, +be aware that the file could be opened in exclusive mode by DBase on the Windows system, and the same file could +be simultaneously opened with a program on the Unix box. That could cause some issues. + +<br><br> +In Unix, a program can not lock a file so another process can not access it.<br> +In Windows, a program can lock a file so another process can not access it.<br> +DBase(tm) supports routines to open files exclusively, preventing other users from opening a file.<br> + +<br><h3>Samba settings</h3> + +If you will be using Samba on Linux/Unix and sharing files between Linux and Windows machines, +you will need to disable oplocks. In the smb.conf file, set:<br> +<h4>oplocks = no</h4> + + + + +<br> +<hr><br> +<p><img src="xbase.jpg"><br><hr> +</BODY> +</HTML> |