@@ -437,23 +437,58 @@ mod sys {
437
437
use std:: os:: unix:: io:: AsRawFd ;
438
438
439
439
pub ( super ) fn lock_shared ( file : & File ) -> Result < ( ) > {
440
- flock ( file, libc:: LOCK_SH )
440
+ #[ cfg( not( target_os = "solaris" ) ) ]
441
+ {
442
+ flock ( file, libc:: LOCK_SH )
443
+ }
444
+ #[ cfg( target_os = "solaris" ) ]
445
+ {
446
+ flock ( file, 1 )
447
+ }
441
448
}
442
449
443
450
pub ( super ) fn lock_exclusive ( file : & File ) -> Result < ( ) > {
444
- flock ( file, libc:: LOCK_EX )
451
+ #[ cfg( not( target_os = "solaris" ) ) ]
452
+ {
453
+ flock ( file, libc:: LOCK_EX )
454
+ }
455
+ #[ cfg( target_os = "solaris" ) ]
456
+ {
457
+ flock ( file, 2 )
458
+ }
445
459
}
446
460
447
461
pub ( super ) fn try_lock_shared ( file : & File ) -> Result < ( ) > {
448
- flock ( file, libc:: LOCK_SH | libc:: LOCK_NB )
462
+ #[ cfg( not( target_os = "solaris" ) ) ]
463
+ {
464
+ flock ( file, libc:: LOCK_SH | libc:: LOCK_NB )
465
+ }
466
+ #[ cfg( target_os = "solaris" ) ]
467
+ {
468
+ flock ( file, 1 | 4 )
469
+ }
449
470
}
450
471
451
472
pub ( super ) fn try_lock_exclusive ( file : & File ) -> Result < ( ) > {
452
- flock ( file, libc:: LOCK_EX | libc:: LOCK_NB )
473
+ #[ cfg( not( target_os = "solaris" ) ) ]
474
+ {
475
+ flock ( file, libc:: LOCK_EX | libc:: LOCK_NB )
476
+ }
477
+ #[ cfg( target_os = "solaris" ) ]
478
+ {
479
+ flock ( file, 2 | 4 )
480
+ }
453
481
}
454
482
455
483
pub ( super ) fn unlock ( file : & File ) -> Result < ( ) > {
456
- flock ( file, libc:: LOCK_UN )
484
+ #[ cfg( not( target_os = "solaris" ) ) ]
485
+ {
486
+ flock ( file, libc:: LOCK_UN )
487
+ }
488
+ #[ cfg( target_os = "solaris" ) ]
489
+ {
490
+ flock ( file, 8 )
491
+ }
457
492
}
458
493
459
494
pub ( super ) fn error_contended ( err : & Error ) -> bool {
@@ -493,18 +528,18 @@ mod sys {
493
528
l_pid : 0 ,
494
529
l_pad : [ 0 , 0 , 0 , 0 ] ,
495
530
} ;
496
- flock. l_type = if flag & libc :: LOCK_UN != 0 {
531
+ flock. l_type = if flag & 8 != 0 {
497
532
libc:: F_UNLCK
498
- } else if flag & libc :: LOCK_EX != 0 {
533
+ } else if flag & 2 != 0 {
499
534
libc:: F_WRLCK
500
- } else if flag & libc :: LOCK_SH != 0 {
535
+ } else if flag & 1 != 0 {
501
536
libc:: F_RDLCK
502
537
} else {
503
538
panic ! ( "unexpected flock() operation" )
504
539
} ;
505
540
506
541
let mut cmd = libc:: F_SETLKW ;
507
- if ( flag & libc :: LOCK_NB ) != 0 {
542
+ if ( flag & 4 ) != 0 {
508
543
cmd = libc:: F_SETLK ;
509
544
}
510
545
0 commit comments