Example #1
0
void RemoteDisco( void )
{
    int         i;

    DosSleep( 500 );    /* make sure last packet gets sent */
    Listening = 0;
    _INITSPXECB( Conn, 1, 0, 0 );
    if( SpxTerminateConnection( Connection, &ConnECB ) == 0 ) {
        while( InUse( ConnECB ) ) IPXRelinquishControl();
    }
    for( i = NUM_REC_BUFFS-1; i >= 0; --i ) {
        if( InUse( RecECB[i] ) ) {
            SpxCancelPacket( &RecECB[i] );
        }
    }
    if( InUse( SendECB ) ) {
        SpxCancelPacket( &SendECB );
    }
    for( i = NUM_REC_BUFFS-1; i >= 0; --i ) {
        ZeroArray( RecHead[i] );
        ZeroArray( RecECB[i] );
    }
    ZeroArray( ConnHead );
    ZeroArray( SendHead );
    ZeroArray( ConnECB );
    ZeroArray( SendECB );
}
Example #2
0
static int FindPartner( void )
{
    BYTE        property_value[130];
    LONG        transport_time;

    if( ReadPropertyValue( (char *)SAPStruct.ASServerIDpacket.serverName,
                           DBG_SERVER_TYPE, "NET_ADDRESS",
                           1, (BYTE *)&property_value ) != 0 ) return( 0 );
    AssignArray( ServHead.destination, property_value );
    if( CIPXGetLocalTarget( ServHead.destination.network,
                            ServECB.immediateAddress, &transport_time ) != 0 ) {
        _DBG_IPX(( "FindPartner -- nobody home\r\n" ));
        return( FALSE );
    }
    RespECB.fragmentDescriptor[1].address = &PartnerSPXSocket;
    CIPXListen( &RespECB );
    CIPXSendPacket( &ServECB );
    while( InUse( ServECB ) ) NothingToDo();
    if( !Completed( ServECB ) ) return( FALSE );
    NothingToDo();
    Tick = 0;
    for( ;; ) {
        if( !InUse( RespECB ) ) {
            _DBG_IPX(( "FindPartner -- %s answered\r\n", Completed( RespECB ) ? "someone" : "noone" ));
            return( Completed( RespECB ) );
        }
        NothingToDo();
        if( Tick > MAX_PARTNER_WAIT ) break;
    }
    CIPXCancelECB( &RespECB );
    return( FALSE );
}
Example #3
0
static trap_retval DoRemotePut( byte *snd, trap_elen len )
{
    WORD        rc;

putstring( "RemotePut\r\n" );
putconnstatus( Connection );
    if( len == 0 ) {
        _INITSPXECB( Send, 1, NULL, 0 );
    } else {
        _INITSPXECB( Send, 2, (char *)snd, len );
    }
    SendECB.hsem = (HSEM) &SendSem;
    SendHead.connectionCtl |= 0x10;
    SendHead.packetLen = _SWAPINT( sizeof( SendHead ) + len );
    DosSemSet( &SendSem );
    rc = SpxSendSequencedPacket( Connection, &SendECB );
    putrc( "SPXSendSequencedPacket", rc );

    for( ;; ) {
        /*
            I don't know what the 0x1001 status is - I can't find it
            in any documentation, but if we don't wait for it to clear,
            things mess up badly.
        */
        if( SendECB.status != SPX_SUCCESSFUL && !InUse( SendECB ) && SendECB.status != 0x1001 )
            break;
        rc = DosSemWait( &SendSem, 1000 );
        if( rc != ERROR_SEM_TIMEOUT ) {
            break;
        }
    }
    SendECB.hsem = 0;
putstring( "Done RemotePut\r\n" );
    return( len );
}
InterruptSignal::~InterruptSignal() {
  invalid_ = true;
  SetEvent();
  while (InUse())
    ;
  if (free_event_) hsaKmtDestroyEvent(event_);
  HSA::hsa_memory_deregister(this, sizeof(InterruptSignal));
}
Example #5
0
// Move the details of the specified file to the current one, and then mark the specified file
// as out of use
void CWorkingFile::TransferDetailsFrom(CWorkingFile& rightHandFile)
{
	// We don't do this to files which are already in use
	ASSERT(!InUse());

	m_sFilename = rightHandFile.m_sFilename;
	m_sDescriptiveName = rightHandFile.m_sDescriptiveName;
	rightHandFile.SetOutOfUse();
	m_attribs = rightHandFile.m_attribs;
}
Example #6
0
static trap_retval DoRemotePut( void *data, trap_elen len )
{
    _DBG_IPX(("RemotePut\r\n"));
    _INITSPXECB( Send, 2, data, len );
    SendHead.connectionControl |= 0x10;
    SendHead.length = _SWAPINT( sizeof( SendHead ) + len );
    CSPXSendSequencedPacket( Connection, &SendECB );
    while( InUse( SendECB ) )
        NothingToDo();
    return( len );
}
Example #7
0
static void PostListens( void )
{
    int         i;

    for( i = NUM_REC_BUFFS-1; i >= 0; --i ) {
        if( !InUse( RecECB[i] ) ) {
            PostAListen( i );
        }
    }
    MyDelay( TICKS_PER_SEC / 5 );
}
Example #8
0
char RemoteConnect( void )
{
    WORD        rc;
    #ifdef SERVER
        if( !Listening ) {
            _INITSPXECB( Conn, 1, 0, 0 );
            rc = SpxListenForConnection( SPXSocket, &ConnECB, 0, 0, &Connection );
            putrc( "SPXListenForConnection", rc );
            Listening = 1;
        } else if( !InUse( ConnECB ) ) {
            PostListens();
            return( 1 );
        }
        IPXRelinquishControl();
    #else
putstring( "RemoteConnect\r\n" );
        _INITSPXECB( Send, 1, NULL, 0 );
        if( ( rc = SpxEstablishConnection( SPXSocket, &SendECB,
                                    0, 0x10, &Connection ) ) == 0 ) {
            int i;

            for( i = 1; i < 20; ++i ) {
putstring( "RemoteConnect loop\r\n" );
                if( !InUse( SendECB ) ) {
                    PostListens();
putstring( "RemoteConnect loop done\r\n" );
                    return( 1 );
                }
                DosSleep( 100 );        /* 20 * 100 is approx 2 seconds */
            }
putstring( "RemoteConnect aborting\r\n" );
            rc = SpxAbortConnection( Connection );
            putrc( "SPXAbortConnection", rc );
        } else {
            putrc( "SPXEstablishConnection", rc );
        }
    #endif
    return( 0 );
}
Example #9
0
bool     
IrcAbstractChannel::event (QEvent *evt)
{
  QEvent::Type  tipo = evt->type();
  switch (tipo) {
  case QEvent::WindowActivate:
    emit InUse (this);
    break;
  default:
    break;
  }
  return QObject::event (evt);
}
Example #10
0
void ServRespESR( void )
{
    if( Completed( ServECB ) && !InUse( RespECB )
            && (ServHead.length == _SWAPINT( sizeof( IPXHeader ) )
                || ServHead.length == _SWAPINT( sizeof( IPXHeader ) + 1 ) ) ) {
        _DBG_IPX(( "ServRespESR responding\r\n" ));
        RespHead.destination = ServHead.source;
        AssignArray( RespECB.immediateAddress , ServECB.immediateAddress );
        RespECB.fragmentDescriptor[1].address = &SPXSocket;
        CIPXSendPacket( &RespECB );
    }
    CIPXListen( &ServECB );
}
Example #11
0
static void PostListens( void )
{
    int         i;

    DosSleep( 0 );
    for( i = NUM_REC_BUFFS-1; i >= 0; --i ) {
        if( !InUse( RecECB[i] ) ) {
            PostAListen( i );
        }
    }
    /* make sure other side get the listens up */
    DosSleep( 100 );
}
Example #12
0
void Embperl::dosub(const char * subname, const std::vector<std::string> * args, int mode)
{//as seen in perlembed docs
#if EQDEBUG >= 5
	if(InUse()) {
		LogFile->write(EQCLog::Debug, "Warning: Perl dosub called for %s when perl is allready in use.\n", subname);
	}
#endif
	in_use = true;
	bool err = false;
	try {
		SV **sp = PL_stack_sp;
	       /* initialize stack pointer      */
	} catch(const char *err)
			{//this should never happen, so if it does, it is something really serious (like a bad perl install), so we'll shutdown.
				EQC::Common::Log(EQCLog::Error,CP_ZONESERVER, "Fatal error initializing perl: %s", err);
				
			}

	dSP;                     
	ENTER;                          /* everything created after here */
	SAVETMPS;                       /* ...is a temporary variable.   */
	PUSHMARK(SP);                   /* remember the stack pointer    */
	if(args && args->size())
	{
		for(std::vector<std::string>::const_iterator i = args->begin(); i != args->end(); ++i)
		{/* push the arguments onto the perl stack  */
			XPUSHs(sv_2mortal(newSVpv(i->c_str(), i->length())));
		}
	}
	
	PUTBACK;                      /* make local stack pointer global */
	int result = call_pv(subname, mode); /*eval our code*/
	
	SPAGAIN;                        /* refresh stack pointer         */

	//if(SvTRUE(ERRSV))
	//{
	//	err = true;
	//}
	
	FREETMPS;                       /* free temp values        */
	LEAVE;                       /* ...and the XPUSHed "mortal" args.*/
	
	in_use = false;
	if(err)
	{
		errmsg = "Perl runtime error: ";
		errmsg += SvPVX(ERRSV);
		throw errmsg.c_str();
	}
}
Example #13
0
//
/// Constructs a wrapper for the current drag imagelist and specifies the location
/// and hotspot of the imagelist.
//
TImageList::TImageList(TPoint& pt, TPoint& hotspot)
{
  Bitmap = 0;
  Handle = TCommCtrl::Dll()->ImageList_GetDragImage(&pt, &hotspot);
  if (Handle)
  {
    int x, y;
    bool r = TCommCtrl::Dll()->ImageList_GetIconSize(Handle, &x, &y);
    CHECK(r); InUse(r);
    ImageSize = TSize(x, y);
  }
  CheckValid();
  WARNX(OwlCommCtrl, !Handle, 0, "Cannot create ImageList");
}
Example #14
0
bool RemoteConnect( void )
{
    PostListens();
    if( !Listening ) {
        _DBG_IPX(("Listening for connection\r\n"));
        _INITSPXECB( Conn, 1, 0, 0 );
        CSPXListenForConnection( 0, 0, &Connection, &ConnECB );
        Listening = 1;
    } else if( !InUse( ConnECB ) && Completed( ConnECB ) ) {
        _DBG_IPX(("Found a connection\r\n"));
        return( TRUE );
    }
    NothingToDo();
    return( FALSE );
}
Example #15
0
		bool SpaceAvailable (int x, int y, int iCellsNeeded)
			{
			if (x + iCellsNeeded > m_iCols)
				return false;
			else if (y + iCellsNeeded > m_iRows)
				return false;
			else
				{
				for (int y1 = 0; y1 < iCellsNeeded; y1++)
					for (int x1 = 0; x1 < iCellsNeeded; x1++)
						if (InUse(x + x1, y + y1))
							return false;

				return true;
				}
			}
Example #16
0
void RemoteUnLink( void )
{
#ifdef SERVER
    ServerDie = DIE_WANT;
#endif
    IpxCloseSocket( IPXSocket );
#ifdef SERVER
    DosSemClear( &BroadCastStop );
    if( InUse( ConnECB ) ) {
        SpxCancelPacket( &ConnECB );
    }
    while( ServerDie != (DIE_WANT|DIE_BROADCAST|DIE_RESPOND) )  {
        IPXRelinquishControl();
    }
#endif
    SpxCloseSocket( SPXSocket );
}
Example #17
0
//
/// Constructs an ImageList right from a bmp, icon or cursor resource in a file.
/// 'type' should be one of the consts from winuser.h:
/// - IMAGE_BITMAP
/// - IMAGE_ICON
/// - IMAGE_CURSOR
/// - IMAGE_ENHMETAFILE   ?
///
/// \todo what really are the acceptable types?
//
TImageList::TImageList(HINSTANCE hI, TResId resName, int imageWidth, int growBy,
                       const TColor& mask, uint type, uint flags)
{
  if (!TCommCtrl::IsAvailable())
    TXCommCtrl::Raise();

  Bitmap = 0;
  Handle = TCommCtrl::Dll()->ImageList_LoadImage(hI, resName, imageWidth, growBy, mask, type, flags);
  if (Handle)
  {
    int x, y;
    bool r = TCommCtrl::Dll()->ImageList_GetIconSize(Handle, &x, &y);
    CHECK(r); InUse(r);
    ImageSize = TSize(x, y);
  }
  CheckValid();
  WARNX(OwlCommCtrl, !Handle, 0, "Cannot create ImageList");
}
Example #18
0
static trap_retval DoRemoteGet( byte *rec, trap_elen len )
{
    int         i;
    int         p;
    unsigned    recvd;
    unsigned    got;

putstring( "RemoteGet\r\n" );
putconnstatus( Connection );

    len = len;
    recvd = 0;
    for( ;; ) {
        DosSemSet( &RecvSem );
        i = NUM_REC_BUFFS-1;
        p = -1;
        for( ;; ) {
            if( i < 0 ) {
                if( p != -1 ) break;
                DosSemWait( &RecvSem, 1000 );
                i = NUM_REC_BUFFS-1;
            }
            if( !InUse( RecECB[i] ) ) {
                if( p == -1
                 || LOWER_SEQ( RecHead[i].sequenceNumber, RecHead[p].sequenceNumber ) ) {
                    p = i;
                }
            }
            --i;
        }
        got = _SWAPINT( RecHead[p].packetLen ) - sizeof( RecHead[p] );
        _fmemcpy( rec, Buffer[p], got );
        recvd += got;
        PostAListen( p );
        if( got != MAX_DATA_SIZE ) break;
        rec += got;
    }

putstring( "Done RemoteGet\r\n" );
    return( recvd );
}
Example #19
0
bool CWorkingFile::HasSourceFileChanged() const
{
	if (!InUse())
	{
		return false;
	}
	WIN32_FILE_ATTRIBUTE_DATA attribs = {0};
	if (PathFileExists(m_sFilename))
	{
		if (GetFileAttributesEx(m_sFilename, GetFileExInfoStandard, &attribs))
		{
			if ( (m_attribs.nFileSizeHigh != attribs.nFileSizeHigh) ||
				(m_attribs.nFileSizeLow != attribs.nFileSizeLow) )
				return true;
			return ( (CompareFileTime(&m_attribs.ftCreationTime, &attribs.ftCreationTime)!=0) ||
				(CompareFileTime(&m_attribs.ftLastWriteTime, &attribs.ftLastWriteTime)!=0) );
		}
	}

	return false;
}
Example #20
0
void RemoteDisco( void )
{
    int         i;

    _DBG_IPX(("RemoteDisco\r\n"));
    /* make sure last packet gets sent out */
    MyDelay( TICKS_PER_SEC/2 );

    Listening = 0;
    _INITSPXECB( Conn, 1, 0, 0 );
    CSPXTerminateConnection( Connection, &ConnECB );
    for( i = NUM_REC_BUFFS-1; i >= 0; --i ) {
        if( InUse( RecECB[i] ) ) {
            SPXCancelEvent( &RecECB[i] );
        }
    }
    SPXCancelEvent( &SendECB );
    for( i = NUM_REC_BUFFS-1; i >= 0; --i ) {
        RecECB[i].status = 0;
    }
}
Example #21
0
static trap_retval DoRemoteGet( void *data, trap_elen len )
{
    trap_elen   recvd;
    int         i;
    trap_elen   got;
    int         p;

    len = len;
    _DBG_IPX(("RemoteGet\r\n"));
    recvd = 0;
    for( ;; ) {
        i = NUM_REC_BUFFS-1;
        p = -1;
        for( ;; ) {
            if( i < 0 ) {
                if( p != -1 )
                    break;
                NothingToDo();
                i = NUM_REC_BUFFS-1;
            }
            if( !InUse( RecECB[i] ) ) {
                if( p == -1
                        || LOWER_SEQ( RecHead[i].sequenceNumber, RecHead[p].sequenceNumber ) ) {
                    p = i;
                }
            }
            --i;
        }
        got = _SWAPINT( RecHead[p].length ) - sizeof( RecHead[p] );
        _DBG_IPX(("Got a packet - size=%d\r\n", got));
        memcpy( data, Buffer[p], got );
        recvd += got;
        PostAListen( p );
        if( got != MAX_DATA_SIZE )
            break;
        data = (char *)data + got;
    }
    return( recvd );
}
Example #22
0
void Embperl::dosub(const char * subname, const std::vector<std::string> * args, int mode)
{//as seen in perlembed docs
#if EQDEBUG >= 5
	if(InUse()) {
		LogFile->write(EQEMuLog::Debug, "Warning: Perl dosub called for %s when perl is allready in use.\n", subname);
	}
#endif
	in_use = true;
	bool err = false;
	dSP;                            /* initialize stack pointer      */
	ENTER;                          /* everything created after here */
	SAVETMPS;                       /* ...is a temporary variable.   */
	PUSHMARK(SP);                   /* remember the stack pointer    */
	if(args && args->size())
	{
		for(std::vector<std::string>::const_iterator i = args->begin(); i != args->end(); ++i)
		{/* push the arguments onto the perl stack  */
			XPUSHs(sv_2mortal(newSVpv(i->c_str(), i->length())));
		}
	}
	PUTBACK;                      /* make local stack pointer global */
	call_pv(subname, mode); /*eval our code*/
	SPAGAIN;                        /* refresh stack pointer         */
	if(SvTRUE(ERRSV))
	{
		err = true;
	}
	FREETMPS;                       /* free temp values        */
	LEAVE;                       /* ...and the XPUSHed "mortal" args.*/

	in_use = false;
	if(err)
	{
		errmsg = "Perl runtime error: ";
		errmsg += SvPVX(ERRSV);
		throw errmsg.c_str();
	}
}
Example #23
0
void ShaderProgram::StopUsing()
{
	assert(InUse());
	glUseProgram(0);
}
DefaultSignal::~DefaultSignal() {
  invalid_ = true;
  while (InUse())
    ;
  HSA::hsa_memory_deregister(this, sizeof(DefaultSignal));
}
TLvItem
TListViewCtrl::GetItem(int index, int subitemIndex) const
{
  TLvItem item;
  bool r = GetItem(item, index, subitemIndex);
  WARN(!r, _T("TListViewCtrl::GetItem failed for index ") << index << _T(".") << subitemIndex); InUse(r);
  return item;
}
Example #26
0
//
/// Overrides TWindow's virtual PerformCreate function. Creates the interface
/// element associated with the MDI frame window.
///
//
TWindow::TPerformCreateReturnType
TMdiFrame::PerformCreate(int arg)
{
  PRECONDITIONX(!(OWL_STRICT && arg), _T("The deprecated argument to PerformCreate is disallowed.")); InUse(arg);
  PRECONDITION(GetModule());
  //
  // An MDI frame must have a menu. Give it an empty one if none is supplied.
  // Use RAII to ensure the menu is released in case of failure.
  //
  struct TMenuGuard  
  {
    HMENU m;
    TMenuGuard(HMENU m_) : m(m_) {}
    ~TMenuGuard() {if (m) DestroyMenu(m);}
    operator HMENU() {return m;}
    HMENU RelinquishOwnership() {HMENU tmp = m; m = 0; return m;}
  }
  menu(Attr.Menu ? LoadMenu(Attr.Menu) : CreateMenu());
  WARNX(OwlWin, !menu, 0, _T("Unable to load menu: ") << Attr.Menu << _T(" from ") << *GetModule());
  THandle h = CreateWindowEx(
    Attr.ExStyle,
    GetClassName(),
    Title,
    Attr.Style,
    Attr.X, Attr.Y, Attr.W, Attr.H,
    Parent ? Parent->GetHandle() : 0,
    menu,
    *GetModule(),
    Attr.Param
    );
  if (h) menu.RelinquishOwnership(); // The menu belongs to the window now.
  OWL_SET_OR_RETURN_HANDLE(h);
}
Example #27
0
//*******************************************************************
void OTempTag::Release()
{
   OTag::Release();
   if( !InUse() )
      delete this;
}
Example #28
0
/// <summary>
/// Pops a server connection from the top of the stack.  If
/// a connection is not available, one is created.  Stale connections
/// are dropped and not reused.
/// </summary>
/// <param name="connProp">
/// Connection to add
/// <param>
MgServerConnection* MgServerConnectionStack::Pop()
{
    // Wait up to 30 seconds for a connection to free up
    ACE_Time_Value delay(30);
    ACE_Time_Value future = ACE_OS::gettimeofday() + delay;
    int acquired = m_activeConnections.acquire(future);
    if (acquired == -1)
    {
        throw new MgConnectionFailedException(L"MgServerConnectionStack.Pop",
            __LINE__, __WFILE__, NULL, L"", NULL);
    }

    ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, m_mutex, NULL));

    MgServerConnection* conn = NULL;

    ACE_Time_Value now = ACE_High_Res_Timer::gettimeofday();

    // Pull a connection from the front of the queue and make sure it's valid.
    conn = NULL;
    while (NULL == conn && m_queue->size() > 0)
    {
        // Grab a connection from the queue
        {
            conn = m_queue->front();
            if (NULL != conn) m_queue->pop_front();
        }

        // And see if it is still valid
        if (NULL != conn)
        {
            if (conn->IsStale(&now))
            {
                SAFE_RELEASE(conn);
                conn = NULL;
            }
            else
            {
                // Check to see if stream is still alive... It better be!
                Ptr<MgStream> stream = conn->GetStream();
                if (stream != NULL)
                {
                    Ptr<MgStreamHelper> helper = stream->GetStreamHelper();
                    if (helper->IsConnected() == false)
                    {
                        stream = NULL;
                        SAFE_RELEASE(conn);
                        conn = NULL;
                    }
                }
                else
                {
                    SAFE_RELEASE(conn);
                    conn = NULL;
                }
            }
        }
    }

    if (NULL != conn)
    {
        InUse(conn);
    }

    // Extra reference count from InUse will be eating by external code
    return conn;
}