Lines Matching defs:lock

28    reasons (fileattr code, probably others).  Commit needs to lock the
87 struct lock {
88 /* This is the directory in which we may have a lock named by the
89 readlock variable, a lock named by the writelock variable, and/or
90 a lock named CVSLCK. The storage is not allocated along with the
91 struct lock; it is allocated by the Reader_Lock caller or in the
96 /* The name of the master lock dir. Usually CVSLCK. */
99 /* The full path to the lock dir, if we are currently holding it.
113 static int set_lock PROTO ((struct lock *lock, int will_wait));
114 static void clear_lock PROTO ((struct lock *lock));
118 static int write_lock PROTO ((struct lock *lock));
119 static void lock_simple_remove PROTO ((struct lock *lock));
123 /* Malloc'd array containing the username of the whoever has the lock.
138 #define L_LOCKED 2 /* lock owned by someone else */
141 repository field is NULL if there is no such lock. */
142 static struct lock global_readlock = {NULL, CVSLCK, NULL};
144 static struct lock global_history_lock = {NULL, CVSHISTORYLCK, NULL};
145 static struct lock global_val_tags_lock = {NULL, CVSVALTAGSLCK, NULL};
163 /* Return a newly malloc'd string containing the name of the lock for the
164 repository REPOSITORY and the lock file name within that directory
165 NAME. Also create the directories in which to put the lock file
183 /* This is the easy case. Because the lock files go directly
244 We don't try to do anything about the permissions on the lock
340 * Remove locks without discarding the lock information
374 /* Remove the lock files. */
376 lock_simple_remove (lock)
377 struct lock *lock;
381 /* If readlock is set, the lock directory *might* have been created, but
387 tmp = lock_name (lock->repository, readlock);
389 error (0, errno, "failed to remove lock %s", tmp);
393 /* If writelock is set, the lock directory *might* have been created, but
399 tmp = lock_name (lock->repository, writelock);
401 error (0, errno, "failed to remove lock %s", tmp);
405 clear_lock (lock);
411 * Create a lock file for readers
450 /* get the lock dir for our own */
453 error (0, 0, "failed to obtain dir lock in repository `%s'",
464 /* write a read-lock */
468 error (0, errno, "cannot create read lock in repository `%s'",
477 /* free the lock dir */
503 error (0, 0, "write lock failed - read-only repository");
517 /* try to lock everything on the list */
533 error (0, 0, "lock failed - giving up");
536 case L_LOCKED: /* Someone already had a lock */
553 error (0, 0, "unknown lock status %d in Writer_Lock",
570 /* if some lock was not OK, just skip this one */
574 /* apply the write lock */
583 * Create a lock file for writers returns L_OK if lock set ok, L_LOCKED if
584 * lock held by someone else or L_ERROR if an error occurred
587 write_lock (lock)
588 struct lock *lock;
596 CLIENT_SERVER_STR, lock->repository);
610 /* make sure the lock dir is ours (not necessarily unique to us!) */
611 status = set_lock (lock, 0);
615 if (readers_exist (lock->repository))
617 /* clean up the lock dir if we created it */
620 clear_lock (lock);
627 /* write the write-lock file */
628 tmp = lock_name (lock->repository, writelock);
634 error (0, errno, "failed to remove lock %s", tmp);
636 /* free the lock dir if we created it */
639 clear_lock (lock);
643 error (0, xerrno, "cannot create write lock in repository `%s'",
644 lock->repository);
658 * readers_exist() returns 0 if there are no reader lock files remaining in
700 * seconds ago, try to clean-up the lock file, and if
770 * lock.
779 set_lock (lock, will_wait)
780 struct lock *lock;
793 masterlock = lock_name (lock->repository, lock->lockdirname);
797 * handlers that do the appropriate things, like remove the lock
809 lock->lockdir = masterlock;
813 lock_obtained (lock->repository);
825 "failed to create lock directory for `%s' (%s)",
826 lock->repository, masterlock);
831 /* Find out who owns the lock. If the lock directory is
833 removed it (thus releasing the lock). */
839 error (0, errno, "couldn't stat lock directory `%s'", masterlock);
847 * ago, try to clean-up the lock directory, and if successful, just
894 lock_wait (lock->repository);
898 if (!lock->lockdir) free (masterlock);
905 * Clear master lock.
908 * lock The lock information.
915 * If we own the master lock directory, its name is stored in LOCK->lockdir.
920 clear_lock (lock)
921 struct lock *lock;
924 if (lock->lockdir)
926 if (CVS_RMDIR (lock->lockdir) < 0)
927 error (0, errno, "failed to remove lock dir `%s'", lock->lockdir);
928 free (lock->lockdir);
929 lock->lockdir = NULL;
937 * Print out a message that the lock is still held, then sleep a while.
950 sprintf (msg, "[%8.8s] waiting for %s's lock in %s",
962 * Print out a message when we obtain a lock.
975 sprintf (msg, "[%8.8s] obtained lock in %s",
992 * Create a list of repositories to lock
1008 p->data = xmalloc (sizeof (struct lock));
1009 ((struct lock *)p->data)->repository = p->key;
1010 ((struct lock *)p->data)->lockdirname = CVSLCK;
1011 ((struct lock *)p->data)->lockdir = NULL;
1028 * Run the recursion processor to find all the dirs to lock and lock all
1038 error (1, 0, "lock failed - giving up");
1043 a lock has been set with lock_dir_for_write; the new lock will replace
1063 node->data = xmalloc (sizeof (struct lock));
1064 ((struct lock *)node->data)->repository = node->key;
1065 ((struct lock *)node->data)->lockdirname = CVSLCK;
1066 ((struct lock *)node->data)->lockdir = NULL;
1076 * gets a write lock for the history or val-tags file.
1082 static int internal_lock PROTO ((struct lock *lock, const char *xrepository));
1084 internal_lock (lock, xrepository)
1085 struct lock *lock;
1089 assert (!lock->repository);
1090 lock->repository = xmalloc (strlen (xrepository) + sizeof (CVSROOTADM) + 2);
1091 sprintf (lock->repository, "%s/%s", xrepository, CVSROOTADM);
1093 /* get the lock dir for our own */
1094 if (set_lock (lock, 1) != L_OK)
1097 error (0, 0, "failed to obtain history lock in repository `%s'",
1109 * removes the write lock for the history or val-tags file, when it exists.
1111 static void internal_clear_lock PROTO((struct lock *lock));
1113 internal_clear_lock (lock)
1114 struct lock *lock;
1117 if (lock->repository)
1119 free (lock->repository);
1120 lock->repository = NULL;
1124 clear_lock (lock);
1140 /* Remove the CVSROOT/history lock, if it exists.
1161 /* Remove the CVSROOT/val-tags lock, if it exists.