proc.h (3499B)
1/* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20#ifndef GUACD_PROC_H 21#define GUACD_PROC_H 22 23#include "config.h" 24 25#include <guacamole/client.h> 26#include <guacamole/parser.h> 27 28#include <unistd.h> 29 30/** 31 * The number of milliseconds to wait for messages in any phase before 32 * timing out and closing the connection with an error. 33 */ 34#define GUACD_TIMEOUT 15000 35 36/** 37 * The number of microseconds to wait for messages in any phase before 38 * timing out and closing the conncetion with an error. This is always 39 * equal to GUACD_TIMEOUT * 1000. 40 */ 41#define GUACD_USEC_TIMEOUT (GUACD_TIMEOUT*1000) 42 43/** 44 * The number of seconds to wait for any particular guac_client instance 45 * to be freed following disconnect. If the free operation does not complete 46 * within this period of time, the associated process will be forcibly 47 * terminated. 48 */ 49#define GUACD_CLIENT_FREE_TIMEOUT 5 50 51/** 52 * Process information of the internal remote desktop client. 53 */ 54typedef struct guacd_proc { 55 56 /** 57 * The process ID of the client. This will only be available to the 58 * parent process. The child process will see this as 0. 59 */ 60 pid_t pid; 61 62 /** 63 * The file descriptor of the UNIX domain socket to use for sending and 64 * receiving file descriptors of new users. This parent will see this 65 * as the file descriptor for communicating with the child and vice 66 * versa. 67 */ 68 int fd_socket; 69 70 /** 71 * The actual client instance. This will be visible to both child and 72 * parent process, but only the child will have a full guac_client 73 * instance, containing handlers from the plugin, etc. 74 * 75 * The parent process will receive a skeleton guac_client, containing only 76 * a proper connection_id and logging handlers. The actual 77 * protocol-specific handling will be absent. 78 */ 79 guac_client* client; 80 81} guacd_proc; 82 83/** 84 * Creates a new background process for handling the given protocol, returning 85 * a structure allowing communication with and monitoring of the process 86 * created. Within the child process, this function does not return - the 87 * entire child process simply terminates instead. 88 * 89 * @param protocol 90 * The protocol for which this process is client being created. 91 * 92 * @return 93 * A newly-allocated process structure pointing to the file descriptor of 94 * the background process specific to the specified protocol, or NULL of 95 * the process could not be created. 96 */ 97guacd_proc* guacd_create_proc(const char* protocol); 98 99/** 100 * Signals the given process to stop accepting new users and clean up. This 101 * will eventually cause the child process to exit. 102 * 103 * @param proc 104 * The process to stop. 105 */ 106void guacd_proc_stop(guacd_proc* proc); 107 108#endif 109