A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/ncbi__lbsm__ipc_8c_source.html below:

NCBI C++ ToolKit: src/connect/ncbi_lbsm_ipc.c Source File

44 #define NCBI_USE_ERRCODE_X Connect_LBSM 76  unsigned short

semnum = (

unsigned

short)((which << 1) + sem);

79

unlock.sem_num = semnum;

81

unlock.sem_flg = IPC_NOWAIT | (

s_SemUndo

[semnum - 1] ? SEM_UNDO : 0);

82  return

semop(

s_Muxid

, &unlock, 1) != 0 && errno != EAGAIN ? -1 : 0;

89  unsigned short

semnum = (

unsigned

short)((which << 1) + sem);

90  unsigned short

accsem = (

unsigned

short)((which << 1) + 2);

92  struct

sembuf lock[2];

96

lock[0].sem_num = semnum;

98

lock[0].sem_flg = wait ? 0 : IPC_NOWAIT;

99

lock[1].sem_num = accsem;

101

lock[1].sem_flg = undo ? SEM_UNDO : 0;

103  if

(semop(

s_Muxid

, lock,

sizeof

(lock)/

sizeof

(lock[0])) == 0) {

110  if

(

error

== ENOSPC) {

112

(

"LBSM %c-locking[%d] w/o undo"

,

113  "RW"

[sem > 1], which + 1));

119  if

(!wait ||

error

!= ENOMEM)

123

(

"LBSM %c-locking[%d] wait(ENOMEM)"

,

124  "RW"

[sem > 1], which + 1));

151  return

!which || errno == EINVAL ? -1 :

s_Shmem_Lock

(0, 1, 1

);

160  static const union semun

arg = { 0 };

161  int

semnum = (which << 1) | 1;

163  int

retval = semctl(

s_Muxid

, ++semnum, SETVAL, arg) < 0 ? 2 : 0;

165

retval |= semctl(

s_Muxid

, --semnum, SETVAL, arg) < 0 ? 1 : 0;

182  unsigned short

semnum = (

unsigned

short)((which << 1) | 1);

184  struct

sembuf rwlock[2];

188

rwlock[0].sem_num = semnum;

189

rwlock[0].sem_op = 0;

190

rwlock[0].sem_flg = 0;

191

rwlock[1].sem_num = semnum;

192

rwlock[1].sem_op = 1;

193

rwlock[1].sem_flg = undo ? SEM_UNDO : 0;

195  if

(semop(

s_Muxid

, rwlock,

sizeof

(rwlock)/

sizeof

(rwlock[0])) == 0) {

205  if

(

error

== ENOSPC) {

207

(

"LBSM PreW-locking[%d] w/o undo"

, which + 1));

213  if

(

error

!= ENOMEM)

217

(

"LBSM PreW-lock[%d] wait(ENOMEM)"

, which + 1));

241

(

"LBSM W-lock[%d] acquire%s"

, which + 1, wait ?

" w/wait"

:

""

));

257  if

((pid = semctl(

s_Muxid

, (which << 1) | 1, GETPID,

dummy

)) > 0) {

258  int self

= (pid_t) pid == getpid();

259  int

other = !

self

&& (kill(pid, 0) == 0 || errno == EPERM);

262  if

(other && kill(pid, SIGTERM) == 0) {

264

(

"Terminating PID %lu"

, (

long

) pid));

268

}

else if

(!

self

) {

271

(

"Unable to kill PID %lu"

, (

long

) pid));

275

(

"LBSM lock[%d] %s revoked from PID %lu (%s)"

,

276

which + 1, killed || !wait ?

"is being"

:

"has to be"

,

277

(

long

) pid,

self

?

"self"

:

278

other ? (killed ?

"killed"

:

"hanging"

) :

"zombie?"

));

279

}

else if

(pid < 0) {

294

sprintf(num,

"%d"

,

val

);

299

(

"LBSM shmem[%d] has %s stuck %s%s"

, which + 1, num,

300

!locked ?

"process"

:

val

> 1 ?

"readers"

:

"reader"

,

301

wait ?

""

:

", revoking lock"

));

316  if

(semctl(

s_Muxid

, (which << 1) + 2, SETVAL, arg) < 0) {

319

(

"LBSM access count[%d] failed to adjust"

,

342

(

"LBSM lock[%d] failed to reset, code %d"

,

350

(

"LBSM W-lock[%d] re-acquire"

, which + 1));

359

(

"LBSM lock[%d] cannot be re-acquired, code %d"

,

376  if

((shmid = shmget(

k_ShmemKey

[which], 0, 0)) != -1 &&

378

((shmem = shmat(shmid, 0, SHM_RDONLY)) && shmem != (

void

*)(-1L)))) {

379  if

(shmid !=

s_Shmid

[which]) {

380  struct

shmid_ds shm_ds;

389

= (

TNCBI_Size

)(shmctl(shmid, IPC_STAT, &shm_ds) != -1

390

? shm_ds.shm_segsz : 0);

412  "LBSM shmem failed to lock for attachment"

);

422

(

"LBSM shmem[%d] %s"

, which + 1,

s_Shmem

[which]

423

?

"access failed"

:

"failed to attach"

));

428

(

"LBSM heap[%p, %p, %d] attached"

,

433  if

(

s_Shmem

[which = !which]) {

456  if

(which != 1 && which != 2) {

458

(

"LBSM shmem[%d?] cannot detach"

, which));

481  return

realloc(mem, newsize);

493  int

one = 0

, two = 0

;

496  for

(

i

= 0;

i

< 2; ++

i

)

498  if

((one = (

s_Shmid

[0] != -1)) | (two = (

s_Shmid

[1] != -1))) {

500

(

"Re-creating existing LBSM shmem segment%s %s%s%s"

,

501

one ^ two ?

""

:

"s"

,

503

one ^ two ?

""

:

" and "

,

519  struct

shmid_ds shm_ds;

528  if

(shmctl(

s_Shmid

[which], IPC_STAT, &shm_ds) == -1)

529

memset(&shm_ds, 0,

sizeof

(shm_ds));

530  if

(own_pid != (pid_t)(-1) && own_pid != shm_ds.shm_cpid) {

532  if

(shm_ds.shm_cpid) {

534

(

"LBSM shmem[%d] not an owner (%lu) to remove"

,

535

which + 1, (

long

) shm_ds.shm_cpid));

538

(

"LBSM shmem[%d] unable to stat"

,which + 1));

547  if

(shmdt(

s_Shmem

[which]) < 0) {

550

(

"LBSM shmem[%d] unable to detach"

, which + 1));

555  if

(own_pid && shmctl(

s_Shmid

[which], IPC_RMID, 0) == -1) {

557  if

(

error

!= EINVAL || own_pid != (pid_t)(-1)

559

|| !(shm_ds.shm_perm.mode & SHM_DEST)

563

(

"LBSM shmem[%d] unable to remove"

, which + 1));

579

pid_t

self

=

heap

? getpid() : 0;

581  for

(

i

= 0;

i

< 2; ++

i

) {

597  assert

(heapbase && heapsize);

600  for

(

i

= 0;

i

< 2; ++

i

) {

623

(

"LBSM shmem[%d] tainted, re-creating"

,

i

+ 1));

628

|| !(shmem = shmat(shmid, 0, 0)) || shmem == (

void

*)(-1L)) {

630

(

"LBSM shmem[%d] unable to re-create"

,

i

+1));

643

memcpy(

s_Shmem

[

i

], heapbase, heapsize);

648

(

"LBSM shmem[%d] failed to unlock, code %d"

,

651  if

(!

code

&& pid && pid != (pid_t)(-1))

660  struct

sembuf lock[2];

664  return

check_n_lock ? 0 : -1;

666 #if defined(NCBI_OS_CYGWIN) && defined(SIGSYS) 668  static void

*

s_SigSysInit = 0

;

670

signal(SIGSYS, SIG_IGN);

683

lock[0].sem_flg = IPC_NOWAIT;

686

lock[1].sem_flg = SEM_UNDO;

687  if

(semop(

id

, lock,

688  sizeof

(lock)/

sizeof

(lock[0]) - (check_n_lock ? 0 : 1)) != 0) {

708  int

shmid = shmget(

k_ShmemKey

[which], 0, 0);

709  struct

shmid_ds shm_ds;

710  if

(shmid != -1 && shmctl(shmid, IPC_STAT, &shm_ds) != -1)

711

pid = shm_ds.shm_cpid;

722

pid = (pid_t) retval;

726  for

(which = 0; which < 2; ++which) {

745  assert

((

int

) pid >= 0);

static int heap[2 *(256+1+29)+1]

void * HEAP_Base(const HEAP heap)

HEAP HEAP_Create(void *base, TNCBI_Size size, TNCBI_Size chunk_size, FHEAP_Resize resize, void *auxarg)

unsigned int HEAP_Destroy(HEAP heap)

int HEAP_Serial(const HEAP heap)

HEAP HEAP_AttachFast(const void *base, TNCBI_Size size, int serial)

HEAP HEAP_Attach(const void *base, TNCBI_Size maxsize, int serial)

unsigned int HEAP_Detach(HEAP heap)

TNCBI_Size HEAP_Size(const HEAP heap)

unsigned int TNCBI_Size

Fixed-size analogs of size_t and time_t (mainly for IPC)

size_t CORE_GetVMPageSize(void)

Obtain virtual memory page size.

void CORE_Msdelay(unsigned long ms)

Delay execution of the current thread by the specified number of milliseconds.

static const CS_INT unused

pid_t LBSM_UnLBSMD(int undaemon)

static int s_Shmem_WLock(int which, int wait)

static const int k_ShmemKey[2]

static TNCBI_Size s_ShmemSize[2]

static int s_Shmem_TryWLock(int which)

static int s_Shmem_Destroy(int which, pid_t own_pid)

static int s_Shmem_RLock(int which)

static int s_Shmem_Lock(int which, int sem, unsigned int wait)

static int s_Shmem_RUnlock(int which)

static int s_Shmem_WUnlock(int which)

HEAP LBSM_Shmem_Create(TNCBI_Size pagesize)

static HEAP s_Shmem_Attach(int which)

int LBSM_LBSMD(int check_n_lock)

void LBSM_Shmem_Detach(HEAP heap)

HEAP LBSM_Shmem_Attach(int fallback)

int LBSM_Shmem_Update(HEAP heap, int wait)

int LBSM_Shmem_Destroy(HEAP heap)

static int s_Shmem_Unlock(int which, int sem)

static void * s_LBSM_ResizeHeap(void *mem, TNCBI_Size newsize, void *unused)

#define LBSM_DEFAULT_PAGE_SIZE

#define CORE_Once(once)

Return non-zero (true) if "*once" had a value of NULL, and set the value to non-NULL regardless (best...

#define CORE_LOG_ERRNO_X(subcode, level, error, message)

#define CORE_LOGF_X(subcode, level, fmt_args)

#define CORE_LOGF_ERRNO_X(subcode, level, error, fmt_args)

#define CORE_LOGF(level, fmt_args)

#define CORE_LOG(level, message)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4