{
- /* Don't remember why I do that */
- set_sem_owner(Address[i+1],ti.team);
+ /* Make sure to have ownership of the semaphore (if created by another team) */
+ TRACEDBGP("->semctl id %d",Address[2*i+1]);
+ set_sem_owner(Address[2*i+1],ti.team);
/* Delete the semaphore */
- delete_sem(Address[i+1]);
+ delete_sem(Address[2*i+1]);
/* Reset to an invalid semId (in case other process try to get the infos from a cloned area */
- Address[i+1]=0;
+ Address[2*i+1]=0;
}
/* Set the semaphore count to 0 */
if (flag==GETNCNT)
{
/* TO BE IMPLEMENTED */
+ TRACEDBG("--semctl getncnt");
elog(ERROR,"beos : semctl error : GETNCNT not implemented");
return 0;
}
if (flag==GETVAL)
{
int32 cnt;
- get_sem_count(Address[semNum+1],&cnt);
+ TRACEDBG("--semctl getval");
+ get_sem_count(Address[2*semNum+1],&cnt);
+ TRACEDBGP("--semctl val %d",cnt);
return cnt;
}
elog(ERROR,"beos : semctl error : unknown flag");
+ TRACEDBG("<-semctl unknown flag");
return 0;
}
area_id parea;
void* Address;
+ TRACEDBGPP("->semget key : %d num : %d",semKey,semNum);
/* Name of the area to find */
sprintf(Nom,"SYSV_IPC_SEM : %d",semKey);
void* Ad;
long i;
- /* Limit to 500 semaphore in a pool */
- if (semNum>500)
+ /* Limit to 250 (8 byte per sem : 4 for the semid and 4 for the last pid
+ which acceced the semaphore in a pool */
+ if (semNum>250)
{
errno=ENOSPC;
return -1;
/* fill up informations (sem number and sem ids) */
Address=(int32*)Ad;
Address[0]=semNum;
- for (i=1;i<=Address[0];i++)
+ for (i=0;i<Address[0];i++)
{
/* Create the semaphores */
- Address[i]=create_sem(0,Nom);
+ Address[2*i+1]=create_sem(0,Nom);
- if ((Address[i]==B_BAD_VALUE)|| (Address[i]==B_NO_MEMORY)||(Address[i]==B_NO_MORE_SEMS))
+ if ((Address[2*i+1]==B_BAD_VALUE)|| (Address[2*i+1]==B_NO_MEMORY)||(Address[2*i+1]==B_NO_MORE_SEMS))
{
errno=ENOMEM;
return -1;
int32* Address; /*Pool address*/
area_info info;
long i;
+ long ret;
/* Get the pool address (semId IS an area id) */
get_area_info(semId,&info);
/* Perform acquire or release */
for(i=0;i
{
+ /* remember the PID */
+ Address[2*(sops[i].sem_num)+2]=getpid();
+
/* For each sem in the pool, check the operation to perform */
if (sops[i].sem_op < 0)
{
/* Try acuiring the semaphore till we are not inteerupted by a signal */
- while (acquire_sem_etc(Address[sops[i].sem_num+1],-sops[i].sem_op,0,0)==B_INTERRUPTED);
+ if (sops[i].sem_flg==IPC_NOWAIT)
+ {
+ /* Try to lock ... */
+ while ((ret=acquire_sem_etc(Address[2*(sops[i].sem_num)+1],-sops[i].sem_op,B_RELATIVE_TIMEOUT,0))==B_INTERRUPTED);
+ if (ret!=B_OK)
+ {
+ return EWOULDBLOCK;
+ }
+ }
+ else
+ {
+ while (acquire_sem_etc(Address[2*(sops[i].sem_num)+1],-sops[i].sem_op,0,0)==B_INTERRUPTED);
+ }
}
if (sops[i].sem_op > 0)
{
- release_sem_etc(Address[sops[i].sem_num+1],sops[i].sem_op,0);
+ release_sem_etc(Address[2*(sops[i].sem_num)+1],sops[i].sem_op,0);
}
}
+
return 0;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/beos.c,v 1.3 2000/10/07 14:39:11 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/beos.c,v 1.4 2000/12/18 18:45:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* Loading symbol */
if(get_image_symbol(*((int*)(handle)),funcname,B_SYMBOL_TYPE_TEXT,(void**)&fpt)==B_OK);
{
+ /* Sometime the loader return B_OK for an inexistant function with an invalid address !!!
+ Check that the return address is in the image range */
+ image_info info;
+ get_image_info(*((int*)(handle)),&info);
+ if ((fpt=(info.text+info.text_size))) return NULL;
return fpt;
}
elog(NOTICE, "loading symbol '%s' failed ",funcname);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.199 2000/12/18 17:33:40 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.200 2000/12/18 18:45:04 momjian Exp $
*
* NOTES
*
fflush(stdout);
fflush(stderr);
+#ifdef __BEOS__
+ /* Specific beos actions before backend startup */
+ beos_before_backend_startup();
+#endif
+
if ((pid = fork()) == 0) /* child */
{
char *av[ARGV_SIZE * 2];
char dbbuf[ARGV_SIZE];
char xlbuf[ARGV_SIZE];
+#ifdef __BEOS__
+ /* Specific beos actions after backend startup */
+ beos_backend_startup();
+#endif
+
/* Lose the postmaster's on-exit routines and port connections */
on_exit_reset();
/* in parent */
if (pid < 0)
{
+#ifdef __BEOS__
+ /* Specific beos actions before backend startup */
+ beos_backend_startup_failed();
+#endif
+
fprintf(stderr, "%s Data Base: fork failed: %s\n",
((xlop == BS_XLOG_STARTUP) ? "Startup" :
((xlop == BS_XLOG_CHECKPOINT) ? "CheckPoint" :
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.196 2000/12/18 17:33:41 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.197 2000/12/18 18:45:05 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.196 $ $Date: 2000/12/18 17:33:41 $\n");
+ puts("$Revision: 1.197 $ $Date: 2000/12/18 18:45:05 $\n");
}
/*
(long int) sys.tv_sec,
(long int) sys.tv_usec);
/* BeOS has rusage but only has some fields, and not these... */
-#if defined(HAVE_GETRUSAGE) && !defined(__BEOS__)
+#if defined(HAVE_GETRUSAGE)
fprintf(StatFp,
"!\t%ld/%ld [%ld/%ld] filesystem blocks in/out\n",
r.ru_inblock - Save_r.ru_inblock,
typedef unsigned char slock_t;
-#define AF_UNIX 1 /* no domain sockets on BeOS */
+#define AF_UNIX 10 /* no domain sockets on BeOS */
+
+/* Beos doesn't have sysnerr but strerror should works on every error */
+extern int sys_nerr;
+
+/* Beos doesn't have all the required getrusage fields */
+#undef HAVE_GETRUSAGE
/* SYS V emulation */
#define IPC_CREAT 512
#define IPC_EXCL 1024
#define IPC_PRIVATE 234564
+#define IPC_NOWAIT 2048
#define EACCESS 2048
#define EIDRM 4096
#define GETNCNT 16384
#define GETVAL 65536
#define SETVAL 131072
+#define GETPID 262144
union semun
{