Changeset: eab780245d0d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=eab780245d0d
Modified Files:
        monetdb5/mal/mal.c
        monetdb5/mal/mal_client.c
        monetdb5/mal/mal_client.h
        monetdb5/mal/mal_debugger.c
        monetdb5/modules/mal/clients.mx
Branch: default
Log Message:

mal_client: cleanup comments and unused code/parts

cleaned up all comments, ran uncrustify, dropped non-functional defines
and fields from Client struct


diffs (truncated from 910 to 300 lines):

diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c
--- a/monetdb5/mal/mal.c
+++ b/monetdb5/mal/mal.c
@@ -259,25 +259,24 @@ int mal_init(void){
 int
 moreClients(int reruns)
 {
-       int freeclient=0, finishing=0, claimed=0, awaiting=0;
+       int freeclient=0, finishing=0, claimed=0;
        Client cntxt = mal_clients;
 
-       freeclient=0; finishing=0; claimed=0; awaiting=0;
+       freeclient=0; finishing=0; claimed=0;
        for(cntxt= mal_clients+1;  cntxt<mal_clients+MAL_MAXCLIENTS; cntxt++){
                freeclient += (cntxt->mode == FREECLIENT);
                finishing += (cntxt->mode == FINISHING);
                claimed += (cntxt->mode == CLAIMED);
-               awaiting += (cntxt->mode == AWAITING);
                if( cntxt->mode & FINISHING)
                        printf("#Client %d %d\n",(int)(cntxt - mal_clients), 
cntxt->idx);
        }
        if( reruns == 3){
                mnstr_printf(mal_clients->fdout,"#MALexit: server forced exit"
-                       " %d finishing %d claimed %d waiting\n",
-                               finishing,claimed,awaiting);
+                       " %d finishing %d claimed\n",
+                               finishing,claimed);
                return 0;
        }
-       return finishing+claimed+awaiting;
+       return finishing+claimed;
 }
 void mal_exit(void){
        int t = 0;
diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c
--- a/monetdb5/mal/mal_client.c
+++ b/monetdb5/mal/mal_client.c
@@ -18,72 +18,38 @@
  */
 
 /*
- * @a M. L. Kersten
- * @v 5.0
- * @-
  * Clients gain access to the Monet server through a internet connection
- * or through its server console.
- * Access through the internet requires a client program at the
- * source, which addresses the default port of a running server.
- * The functionality of the server console is limited.
+ * or through its server console.  Access through the internet requires
+ * a client program at the source, which addresses the default port of a
+ * running server.  The functionality of the server console is limited.
  * It is a textual interface for expert use.
  *
- * @ifset M5manual
- * At the server side, each client is represented by a session record with the
- * current status, such as name, file descriptors, namespace, and local stack.
- * Each client session has a dedicated thread of control, which limits
- * the number of concurrent users to the thread management facilities of the
- * underlying operating system. A large client base should be supported using
- * a single server-side client thread, geared at providing
- * a particular service.
+ * At the server side, each client is represented by a session record
+ * with the current status, such as name, file descriptors, namespace,
+ * and local stack.  Each client session has a dedicated thread of
+ * control.
  *
- * The number of clients permitted concurrent access is
- * a compile time option. The console is the first and is always present.
- * It reads from standard input and writes to standard output.
- * @end ifset
+ * The number of clients permitted concurrent access is a run time
+ * option. The console is the first and is always present.  It reads
+ * from standard input and writes to standard output.
  *
  * Client sessions remain in existence until the corresponding
- * communication channels break or its retention timer expires
- * The administrator and owner of a sesssion
- * can manipulate the timeout with a system call.
+ * communication channels break.
  *
- * @ifset sqlmanual
- * There are many user-friendly tools to interact with a SQL database server.
- * A few based on the JDBC library of MonetDB are included for reference only.
- * @end ifset
- * Client records are linked into a hierarchy, where the top record
- * denotes the context of the Monet administrator. The next layer
- * is formed by a database administrator and the third layer contains
- * user sessions.
- * This hierachy is used to share and constrain resources, such
- * as global variables or references to catalogue information.
- * During parallel execution additional layers may be constructed.
- * [This feature needs more implementation support]
+ * A client record is initialized upon acceptance of a connection.  The
+ * client runs in his own thread of control until it finds a
+ * soft-termination request mode (FINISHING) or its IO file descriptors
+ * are closed. The latter generates an IO error, which leads to a safe
+ * termination.
  *
- * The routines defined below provide management of the client
- * administration. Routines dealing with serviceing requests
- * are located in mal_startup.
+ * The system administrator client runs in the primary thread of control
+ * to simplify debugging with external debuggers.
+ *
+ * Searching a free client record is encapsulated in a critical section
+ * to hand them out one-at-a-time.  Marking them as being claimed avoids
+ * any interference from parallel actions to obtain client records.
  */
-/*
- * @-
- *
- * A client record is initialized upon acceptance of a connection.
- * The client runs in his own thread of control until it finds a
- * soft-termination request mode (FINISHING) or its IO file
- * descriptors are closed. The latter generates an IO error, which
- * leads to a safe termination.
- *
- * The system administrator client runs in the primary thread of
- * control to simplify debugging with external debuggers.
- *
- * A new Client structure can only be requested if the 'adm'
- * user is available, because it guarantees a way to deliver
- * ny error message.
- * Searching a free client record is encapsulated in
- * a critical section to hand them out one-at-a-time.
- * Marking them as being claimed avoids any interference from parallel
- * actions to obtain client records.
- */
+
 #include "monetdb_config.h"
 #include "mal_client.h"
 #include "mal_readline.h"
@@ -93,21 +59,18 @@
 #include <mapi.h> /* for PROMPT1 */
 
 
-/* This should be in src/mal/mal.h, as the function is implemented in
- * src/mal/mal.c; however, it cannot, as "Client" isn't known there ... |-(
- * For now, we move the prototype here, as it it only used here.
- * Maybe, we should concider also moving the implementation here...
-
-int streamClient(Client c, str prompt);
-int bstreamClient(Client c, str prompt);
+/*
+ * This should be in src/mal/mal.h, as the function is implemented in
+ * src/mal/mal.c; however, it cannot, as "Client" isn't known there ...
+ * |-( For now, we move the prototype here, as it it only used here.
+ * Maybe, we should consider also moving the implementation here...
  */
 
-static void     freeClient  (Client c);
+static void freeClient(Client c);
 
 int MAL_MAXCLIENTS = 0;
-ClientRec   *mal_clients;
-/*int MCdefault= threadFlag | bigfootFlag;*/
-int MCdefault= 0;
+ClientRec *mal_clients;
+int MCdefault = 0;
 
 void
 MCinit(void)
@@ -130,10 +93,11 @@ MCinit(void)
        mal_clients = GDKzalloc(sizeof(ClientRec) * MAL_MAXCLIENTS);
 }
 
-int MCpushClientInput(Client c, bstream *new_input, int listing, char *prompt)
+int
+MCpushClientInput(Client c, bstream *new_input, int listing, char *prompt)
 {
-       ClientInput *x = (ClientInput*)GDKmalloc(sizeof(ClientInput));
-       if ( x == 0 )
+       ClientInput *x = (ClientInput *) GDKmalloc(sizeof(ClientInput));
+       if (x == 0)
                return -1;
        x->fdin = c->fdin;
        x->yycur = c->yycur;
@@ -143,13 +107,14 @@ int MCpushClientInput(Client c, bstream 
        c->bak = x;
        c->fdin = new_input;
        c->listing = listing;
-       c->prompt = prompt? GDKstrdup(prompt):GDKstrdup("");
+       c->prompt = prompt ? GDKstrdup(prompt) : GDKstrdup("");
        c->promptlength = strlen(c->prompt);
        c->yycur = 0;
        return 0;
 }
 
-void MCpopClientInput(Client c)
+void
+MCpopClientInput(Client c)
 {
        ClientInput *x = c->bak;
        if (c->fdin) {
@@ -192,22 +157,24 @@ MCnewClient(void)
 #endif
        return c;
 }
+
 /*
  * You can always retrieve a client record using the thread identifier,
- * because we maintain a 1-1 mapping between client and thread of control.
- * Therefore, we don't need locks either.
+ * because we maintain a 1-1 mapping between client and thread of
+ * control.  Therefore, we don't need locks either.
  * If the number of clients becomes too large, we have to change the
  * allocation and lookup scheme.
  *
- * Finding a client record is tricky when we are spawning threads
- * as co-workers. It is currently passed as an argument.
+ * Finding a client record is tricky when we are spawning threads as
+ * co-workers. It is currently passed as an argument.
  */
 
-Client MCgetClient(int id)
+Client
+MCgetClient(int id)
 {
        if (id < 0 || id > MAL_MAXCLIENTS)
                return NULL;
-       return(mal_clients + id);
+       return mal_clients + id;
 }
 
 static void
@@ -218,21 +185,22 @@ MCexitClient(Client c)
 #endif
        MPresetProfiler(c->fdout);
        if (c->father == NULL) { /* normal client */
-               if( c->fdout && c->fdout != GDKstdout){
+               if (c->fdout && c->fdout != GDKstdout) {
                        (void) mnstr_close(c->fdout);
                        (void) mnstr_destroy(c->fdout);
                }
-               assert(c->bak==NULL);
-               if(c->fdin){
+               assert(c->bak == NULL);
+               if (c->fdin) {
                        /* missing protection against closing stdin stream */
                        (void) bstream_destroy(c->fdin);
                }
                c->fdout = NULL;
-               c->fdin= NULL;
+               c->fdin = NULL;
        }
 }
 
-Client MCinitClient(oid user, bstream *fin, stream *fout) 
+Client
+MCinitClient(oid user, bstream *fin, stream *fout)
 {
        Client c = NULL;
        str prompt;
@@ -246,7 +214,7 @@ Client MCinitClient(oid user, bstream *f
        c->srcFile = NULL;
        c->blkmode = 0;
 
-       c->fdin = fin ? fin : bstream_create(GDKin,0);
+       c->fdin = fin ? fin : bstream_create(GDKin, 0);
        c->yycur = 0;
        c->bak = NULL;
 
@@ -258,32 +226,31 @@ Client MCinitClient(oid user, bstream *f
        c->glb = 0;
 
        /* remove garbage from previous connection */
-       if( c->nspace) {
+       if (c->nspace) {
                freeModule(c->nspace);
-               c->nspace=0;
+               c->nspace = 0;
        }
 
        c->father = NULL;
-       c->login = c->lastcmd= time(0);
-       c->delay= TIMEOUT;
-       c->qtimeout= 0;
-       c->stimeout= 0;
+       c->login = c->lastcmd = time(0);
+       c->qtimeout = 0;
+       c->stimeout = 0;
        c->stage = 0;
        c->itrace = 0;
-       c->debugOptimizer = c->debugScheduler= 0;
-       c->flags= MCdefault;
+       c->debugOptimizer = c->debugScheduler = 0;
+       c->flags = MCdefault;
        c->timer = 0;
        c->bigfoot = 0;
        c->vmfoot = 0;
        c->memory = 0;
        c->errbuf = 0;
 
-       prompt = !fin? GDKgetenv("monet_prompt"): PROMPT1;
-       c->prompt= GDKstrdup(prompt);
-       c->promptlength= strlen(prompt);
+       prompt = !fin ? GDKgetenv("monet_prompt") : PROMPT1;
+       c->prompt = GDKstrdup(prompt);
+       c->promptlength = strlen(prompt);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to