FOSSology  4.4.0
Open Source License Compliance by Open Source Software
interface.c File Reference

Scheduler interface operations. More...

#include <agent.h>
#include <database.h>
#include <event.h>
#include <interface.h>
#include <job.h>
#include <logging.h>
#include <scheduler.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <fcntl.h>
#include <pthread.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <glib.h>
#include <gio/gio.h>
Include dependency graph for interface.c:

Go to the source code of this file.

Classes

struct  interface_connection
 

Macros

#define FIELD_WIDTH   10
 
#define BUFFER_SIZE   1024
 
#define netw   g_output_stream_write
 
#define PROXY_PROTOCOL   "socks5"
 
#define PROXY_DEFAULT_PORT   1080
 

Typedefs

typedef struct interface_connection interface_connection
 

Functions

static interface_connectioninterface_conn_init (GSocketConnection *conn, GThreadPool *threads)
 
static void interface_conn_destroy (interface_connection *inter)
 Free the memory associated with an interface connection. More...
 
void interface_thread (interface_connection *conn, scheduler_t *scheduler)
 Function that will run the thread associated with a particular interface instance. More...
 
void * interface_listen_thread (scheduler_t *scheduler)
 Function that will listen for new connections to the server sockets. More...
 
void interface_init (scheduler_t *scheduler)
 Create the interface thread and thread pool that handle UI connections. More...
 
void interface_destroy (scheduler_t *scheduler)
 Closes the server socket and thread pool that service UI connections. More...
 

Detailed Description

Scheduler interface operations.

Definition in file interface.c.

Typedef Documentation

◆ interface_connection

Data needed to manage the connection between the scheduler any type of interface. This includes the thread, the socket and the GInputStream and GOutputStream

Function Documentation

◆ interface_conn_destroy()

static void interface_conn_destroy ( interface_connection inter)
static

Free the memory associated with an interface connection.

Note
This will block until the thread associated with the interface has closed correctly.
Parameters
interthe interface_connection that should be freed

Definition at line 92 of file interface.c.

◆ interface_conn_init()

static interface_connection* interface_conn_init ( GSocketConnection *  conn,
GThreadPool *  threads 
)
static

Given a new socket, this will create the interface connection structure.

Parameters
connThe socket that this interface is connected to
threadsThread pool handling sockets
Returns
the newly allocated and populated interface connection

Definition at line 71 of file interface.c.

◆ interface_destroy()

void interface_destroy ( scheduler_t scheduler)

Closes the server socket and thread pool that service UI connections.

Note
If interface_destroy() is called before interface_init(), then it will be a no-op.

Definition at line 588 of file interface.c.

◆ interface_init()

void interface_init ( scheduler_t scheduler)

Create the interface thread and thread pool that handle UI connections.

The GUI and the CLI use a socket connection to communicate with the scheduler. This function creates the socket connection as well as everything needed to handle incoming connections and messages.

Note
If interface_init() is called multiple times without a call to interface_destroy(), it will become a no-op after the second call

Definition at line 554 of file interface.c.

◆ interface_listen_thread()

void* interface_listen_thread ( scheduler_t scheduler)

Function that will listen for new connections to the server sockets.

This creates a g_socket_listener and will loop waiting for new connections until the scheduler is closed.

Parameters
schedulerRelevant scheduler structure
Returns
(void*)0 on failure, (void*)1 on success

Definition at line 494 of file interface.c.

◆ interface_thread()

void interface_thread ( interface_connection conn,
scheduler_t scheduler 
)

Function that will run the thread associated with a particular interface instance.

Since multiple different command line a graphical user interfaces can exists simultaneously, this allows the scheduler to quickly perform any requests.

Handle commands:

Command Description
exit Close connection with scheduler
kill Kill a particular job
load Get the host status
close Shutdown the scheduler
pause Pause a job that is currently running
reload Reload configuration information
status Request status for scheduler or job
restart Restart a paused job
verbose Change verbose level for scheduler or job
priority Change the priority of job
database Check the database job queue
Parameters
connPointer to the interface_connection structure
schedulerPointer to the relevant scheduler structure
Returns
not currently used

Definition at line 126 of file interface.c.