vpnengine/vpncommon/src/srvstatic.cpp
changeset 0 33413c0669b9
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 /*
       
     2 * Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Creates and starts a server
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <e32svr.h>
       
    21 
       
    22 #include "srvstarter.h"
       
    23 
       
    24 static void RunServerL()
       
    25 //
       
    26 // Perform all server initialisation, in particular creation of the
       
    27 // scheduler and server and then run the scheduler
       
    28 //
       
    29     {
       
    30     // create and install the active scheduler we need
       
    31     CActiveScheduler* s=new(ELeave) CActiveScheduler;
       
    32     CleanupStack::PushL(s);
       
    33     CActiveScheduler::Install(s);
       
    34     
       
    35     // create the server
       
    36     CServer2* server = Starter::CreateAndStartServerL();
       
    37     CleanupStack::PushL(server);
       
    38     
       
    39     // naming the server thread after server startup helps to debug panics
       
    40     User::LeaveIfError(RThread::RenameMe(Starter::ServerName()));
       
    41     
       
    42     // Initialisation complete, now signal the client
       
    43     RProcess::Rendezvous(KErrNone);
       
    44     
       
    45     // Ready to run
       
    46     CActiveScheduler::Start();
       
    47     
       
    48     // Cleanup the server and scheduler
       
    49     CleanupStack::PopAndDestroy(2); // server, s
       
    50     }
       
    51 
       
    52 TInt E32Main()
       
    53 //
       
    54 // Server process entry-point
       
    55 //
       
    56     {
       
    57     __UHEAP_MARK;
       
    58     
       
    59     CTrapCleanup* cleanup=CTrapCleanup::New();
       
    60     TInt r=KErrNoMemory;
       
    61     if (cleanup)
       
    62         {
       
    63         TRAP(r,RunServerL());
       
    64         delete cleanup;
       
    65         }
       
    66     
       
    67     __UHEAP_MARKEND;
       
    68     return r;
       
    69     }