Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[livejournal] r20616: LJSUP-10483 (Selfpromo delivery mechanic...

Committer: ailyin
LJSUP-10483 (Selfpromo delivery mechanics is broken)
U   trunk/cgi-bin/ljdb.pl
Modified: trunk/cgi-bin/ljdb.pl
===================================================================
--- trunk/cgi-bin/ljdb.pl	2011-11-23 14:21:59 UTC (rev 20615)
+++ trunk/cgi-bin/ljdb.pl	2011-11-23 14:25:18 UTC (rev 20616)
@@ -501,6 +501,27 @@
     return 1;
 }
 
+sub lock_taken {
+    my ( $db, $dbrole, $lockname ) = @_;
+
+    return unless $db && $lockname;
+    return unless $dbrole eq 'global' || $dbrole eq 'user';
+
+    my ($connid) = $db->selectrow_array( 'SELECT IS_USED_LOCK(?)',
+        undef, $lockname );
+
+    return $connid ? 1 : 0;
+}
+
+sub lock_free {
+    my ( $db, $dbrole, $lockname ) = @_;
+
+    return unless $db && $lockname;
+    return unless $dbrole eq 'global' || $dbrole eq 'user';
+
+    return ! lock_taken( $db, $dbrole, $lockname );
+}
+
 # <LJFUNC>
 # name: LJ::disconnect_dbs
 # des: Clear cached DB handles

Tags: ailyin, andy, livejournal, pl
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments