Esempio n. 1
0
/*
** Name: ddc_dbtimeout_get
**
** Description:
**
**
** Inputs:
**
**      offset          offset to add to base object pointer.
**      objsize         size of object (ignored)
**      obj             pointer to bas object
**      userbuflen      size of the user buffer
**
** Outputs:
**
**      userbuf         updated user buffer with the cursor owner name.
**
** Returns:
**      OK                  successfully completed
**      MO_VALUE_TRUNCATED  buffer too short
**
** History:
**      02-Jul-98 (fanra01)
**          Created.
**
*/
STATUS
ddc_dbtimeout_get (i4 offset, i4 objsize, PTR obj, i4 userbuflen,
                   char * userbuf)
{
    PDB_CACHED_SESSION  session = (PDB_CACHED_SESSION) obj;
	i4	left = (session->timeout_end == 0) ? 0 : session->timeout_end - TMsecs();

	return(MOlongout (MO_VALUE_TRUNCATED, left,
               userbuflen, userbuf));
}
Esempio n. 2
0
STATUS
CS_thread_id_get(i4 offset,
		i4 objsize,
		PTR object,
		i4 luserbuf,
		char *userbuf)
{
    char buf[ 20 ];
    char *str = buf;
    CS_SCB *scb = (CS_SCB *)object;

    /*
    ** If CS_THREAD_ID is a structure, this will need to be
    ** modified to fit!
    */
    (void) MOlongout( 0, *(i8*)&scb->cs_thread_id, sizeof(buf), buf );

    return( MOstrout( MO_VALUE_TRUNCATED, str, luserbuf, userbuf ));
}
Esempio n. 3
0
STATUS
CS_scb_thread_type_get(i4 offset,
		       i4 objsize,
		       PTR object,
		       i4 luserbuf,
		       char *userbuf)
{
    CS_SCB *scb = (CS_SCB *)object;
    char buf[ 80 ];
    char *str = buf;

    if( scb->cs_thread_type == CS_INTRNL_THREAD )
	str = "internal";
    else if( scb->cs_thread_type == CS_USER_THREAD )
	str = "user";
    else
	(void) MOlongout( 0, scb->cs_thread_type, sizeof(buf), buf );

    return( MOstrout( MO_VALUE_TRUNCATED, str, luserbuf, userbuf ));
}
Esempio n. 4
0
/*{
** Name:	CS_scb_cpu_get	- MO get function for session_cpu field.
**
** Description:
**	Obtain the cpu time this thread has used from the OS.
**	On some platforms this is not possible, so for these 
**	we return zero.
**
** Re-entrancy:
**	yes.
**
** Inputs:
**	offset		offset into the SCB of the mask field.
**	objsize		size of the mask field, ignored.
**	object		the CS_SCB in question.
**	luserbuf	length of output buffer
**
** Outputs:
**	userbuf		The total amount of cpu time in milliseconds
**			used by this thread.
**
** Returns:
**	Standard get function returns. Note that the aim is NOT to 
**	return an error if at all possible. This is because returning an 
**	error in IMA for even just one value in one row causes no data 
**	to be returned for ANY rows in the query, with no error message 
**	to the front end client. A reasonable alternative is to return 
**	zero as the value. 
**
** History:
**	09-Feb-2009 (smeke01) b119586 
**	    Created.  
*/
STATUS
CS_scb_cpu_get(i4  offset,
		i4  objsize,
		PTR object,
		i4  luserbuf,
		char *userbuf)
{
    i4		totalcpu = 0;
    CS_SCB	*pSCB = (CS_SCB *) object;
    CS_THREAD_STATS_CB thread_stats_cb;

#if defined (OS_THREADS_USED) && (defined(LNX) || defined(sparc_sol))
    thread_stats_cb.cs_thread_id = pSCB->cs_thread_id; 
    thread_stats_cb.cs_os_pid = pSCB->cs_os_pid;
    thread_stats_cb.cs_os_tid = pSCB->cs_os_tid;
    thread_stats_cb.cs_stats_flag = CS_THREAD_STATS_CPU; 
    if (CSMT_get_thread_stats(&thread_stats_cb) == OK)
	totalcpu = thread_stats_cb.cs_usercpu + thread_stats_cb.cs_systemcpu;
#else
    totalcpu = pSCB->cs_cputime;
#endif
    return (MOlongout(MO_VALUE_TRUNCATED, totalcpu, luserbuf, userbuf));
}
Esempio n. 5
0
static STATUS
ADFmo_fi_index(
    i4	    msg,
    PTR	    cdata,
    i4	    linstance,
    char    *instance,
    PTR	    *instdata)
{
    ADI_FI_DESC *fi;
    STATUS	    status;
    i4	    ix;
    i4         maxix = Adf_globs->Adi_num_fis;

    CVal(instance, &ix);

    switch (msg)
    {
	case MO_GET:
	    if (ix < 1 || ix > maxix )
	    {
		  status = MO_NO_INSTANCE;
		  break;
	    }
	    fi = &Adf_globs->Adi_fis[ix];
	    if ((fi == NULL) ||
		(fi->adi_finstid < 1))
	    {
		  status = MO_NO_INSTANCE;
		  break;
	    }

	    *instdata = (PTR)fi;
	    status = OK;

	    break;

	case MO_GETNEXT:
	    while (++ix <= maxix)
	    {
	      fi = &Adf_globs->Adi_fis[ix];
	      if ((fi == NULL) ||
	          (fi->adi_finstid < 1))
	      {
	        continue;
	      }
	      else
	      {
	        *instdata = (PTR)fi;
	        status = MOlongout( MO_INSTANCE_TRUNCATED,
					(i8)ix,
					linstance, instance);
	        break;
	      }
	    }
	    if (ix > maxix)
		status = MO_NO_INSTANCE;
		
	    break;

	default:
	    status = MO_BAD_MSG;
	    break;
    }

    return (status);
}
Esempio n. 6
0
static STATUS
ADFmo_op_index(
    i4	    msg,
    PTR	    cdata,
    i4	    linstance,
    char    *instance,
    PTR	    *instdata)
{
    ADI_OPRATION *op;
    STATUS	    status;
    i4	    ix;
    i4         maxix = (Adf_globs->Adi_op_size) / sizeof(ADI_OPRATION);

    CVal(instance, &ix);

    switch(msg)
    {
	case MO_GET:
	    if (ix < 1 || ix > maxix )
	    {
		  status = MO_NO_INSTANCE;
		  break;
	    }
	    op = &Adf_globs->Adi_operations[ix];
	    if ((op == NULL) ||
		(op->adi_opid < 1))
	    {
		  status = MO_NO_INSTANCE;
		  break;
	    }

	    *instdata = (PTR)op;
	    status = OK;

	    break;

	case MO_GETNEXT:
	    while (++ix <= maxix)
	    {
	      op = &Adf_globs->Adi_operations[ix];
	          if ((op == NULL) ||
		      (op->adi_opid < 1))
		  {
		    continue;
		  }
		  else
		  {
		    *instdata = (PTR)op;
		    status = MOlongout( MO_INSTANCE_TRUNCATED,
					(i8)ix,
					linstance, instance);
		    break;
		  }
	    }
	    if (ix > maxix)
		status = MO_NO_INSTANCE;
		
	    break;

	default:
	    status = MO_BAD_MSG;
	    break;
    }

    return (status);
}
Esempio n. 7
0
static STATUS
ADFmo_dt_index(
    i4	    msg,
    PTR	    cdata,
    i4	    linstance,
    char    *instance,
    PTR	    *instdata)
{
    ADI_DATATYPE *dt;
    STATUS	    status;
    i4	    ix;
    i4	    maxix = (Adf_globs->Adi_dt_size) / sizeof(ADI_DATATYPE);

    CVal(instance, &ix);

    switch(msg)
    {
	case MO_GET:
	    if (ix < 1 || ix > maxix )
	    {
		  status = MO_NO_INSTANCE;
		  break;
	    }
	    dt = &Adf_globs->Adi_datatypes[ix];
	    if ((dt == NULL) ||
		(dt->adi_dtid < 1))
	    {
		  status = MO_NO_INSTANCE;
		  break;
	    }

	    *instdata = (PTR)dt;
	    status = OK;

	    break;

	case MO_GETNEXT:
	    while (++ix <= maxix)
	    {
	      dt = &Adf_globs->Adi_datatypes[ix];
	          if ((dt == NULL) ||
		      (dt->adi_dtid < 1))
		  {
		    continue;
		  }
		  else
		  {
		    *instdata = (PTR)dt;
		    status = MOlongout( MO_INSTANCE_TRUNCATED,
					(i8)ix,
					linstance, instance);
		    break;
		  }
	    }
	    if (ix > maxix)
		status = MO_NO_INSTANCE;
		
	    break;

	default:
	    status = MO_BAD_MSG;
	    break;
    }

    return (status);
}