Changeset 928


Ignore:
Timestamp:
2012-06-26T11:03:38+02:00 (22 months ago)
Author:
moo
Message:

fix locking for win32

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lock.c

    r393 r928  
    99#       define INVALID_HANDLE_VALUE -1 
    1010#   endif 
    11 #   define CloseHandle(h) close(h) 
     11#else 
     12#   define close(h) CloseHandle(h) 
     13#   define open(filename, mode, permission) CreateFile(filename, \ 
     14        GENERIC_READ | GENERIC_WRITE, \ 
     15        FILE_SHARE_READ | FILE_SHARE_WRITE, \ 
     16        NULL, \ 
     17        OPEN_ALWAYS, \ 
     18        FILE_ATTRIBUTE_NORMAL, \ 
     19        NULL) 
    1220#endif 
    1321#include "lock.h" 
     
    5058#   include <sys/types.h> 
    5159#   include <sys/stat.h> 
    52 #   ifndef errno 
    53 #       define errno GetLastError() 
    54 #   endif 
     60#   undef errno 
     61#   define errno GetLastError() 
    5562#   define getuid() 0 
    5663#   define LCK_WR LOCKFILE_EXCLUSIVE_LOCK 
     
    100107    } 
    101108 
    102     fd = (HANDLE) open(pathname, O_RDWR|O_CREAT, 0666); 
     109    fd = open(pathname, O_RDWR|O_CREAT, 0666); 
    103110 
    104111    if (fd != INVALID_HANDLE_VALUE) { 
     
    114121    } 
    115122    else { 
    116         fprintf(stderr, "xc_fcntl_create: open(%s, O_RDWR|O_CREAT, 0666) failed:", pathname); 
     123        zend_error(E_ERROR, "xc_fcntl_create: open(%s, O_RDWR|O_CREAT, 0666) failed:", pathname); 
    117124        lck = NULL; 
    118125    } 
     
    127134void xc_fcntl_destroy(xc_lock_t *lck) /* {{{ */ 
    128135{    
    129     CloseHandle(lck->fd); 
     136    close(lck->fd); 
    130137#ifdef __CYGWIN__ 
    131138    unlink(lck->pathname); 
     
    138145{    
    139146    if (dolock(lck, LCK_WR) < 0) { 
    140         fprintf(stderr, "xc_fcntl_lock failed errno:%d", errno); 
     147        zend_error(E_ERROR, "xc_fcntl_lock failed errno:%d", errno); 
    141148    } 
    142149} 
     
    145152{    
    146153    if (dolock(lck, LCK_RD) < 0) { 
    147         fprintf(stderr, "xc_fcntl_lock failed errno:%d", errno); 
     154        zend_error(E_ERROR, "xc_fcntl_lock failed errno:%d", errno); 
    148155    } 
    149156} 
     
    152159{    
    153160    if (dolock(lck, LCK_UN) < 0) { 
    154         fprintf(stderr, "xc_fcntl_unlock failed errno:%d", errno); 
     161        zend_error(E_ERROR, "xc_fcntl_unlock failed errno:%d", errno); 
    155162    } 
    156163} 
Note: See TracChangeset for help on using the changeset viewer.