diff options
| -rw-r--r-- | meta/packages/pseudo/pseudo/data-as-env.patch | 230 | ||||
| -rw-r--r-- | meta/packages/pseudo/pseudo_git.bb | 2 |
2 files changed, 223 insertions, 9 deletions
diff --git a/meta/packages/pseudo/pseudo/data-as-env.patch b/meta/packages/pseudo/pseudo/data-as-env.patch index 4b2b5d0a60..14473cc187 100644 --- a/meta/packages/pseudo/pseudo/data-as-env.patch +++ b/meta/packages/pseudo/pseudo/data-as-env.patch | |||
| @@ -7,10 +7,14 @@ database. This should enable us to use a different database for each run of | |||
| 7 | pseudo. | 7 | pseudo. |
| 8 | 8 | ||
| 9 | JL (23/07/10) | 9 | JL (23/07/10) |
| 10 | |||
| 11 | Updates to include lock/log/socket/pid files | ||
| 12 | |||
| 13 | RP (24/07/10) | ||
| 10 | Index: git/pseudo.h | 14 | Index: git/pseudo.h |
| 11 | =================================================================== | 15 | =================================================================== |
| 12 | --- git.orig/pseudo.h 2010-07-23 12:12:21.000000000 +0100 | 16 | --- git.orig/pseudo.h 2010-07-24 00:28:35.762423800 +0100 |
| 13 | +++ git/pseudo.h 2010-07-23 13:35:29.044856965 +0100 | 17 | +++ git/pseudo.h 2010-07-24 10:34:33.902335659 +0100 |
| 14 | @@ -123,6 +123,7 @@ | 18 | @@ -123,6 +123,7 @@ |
| 15 | extern char *pseudo_fix_path(const char *, const char *, size_t, size_t, size_t *, int); | 19 | extern char *pseudo_fix_path(const char *, const char *, size_t, size_t, size_t *, int); |
| 16 | extern char **pseudo_dropenv(char * const *); | 20 | extern char **pseudo_dropenv(char * const *); |
| @@ -19,10 +23,31 @@ Index: git/pseudo.h | |||
| 19 | extern char *pseudo_prefix_path(char *); | 23 | extern char *pseudo_prefix_path(char *); |
| 20 | extern char *pseudo_get_prefix(char *); | 24 | extern char *pseudo_get_prefix(char *); |
| 21 | extern int pseudo_logfile(char *defname); | 25 | extern int pseudo_logfile(char *defname); |
| 26 | @@ -134,10 +135,16 @@ | ||
| 27 | |||
| 28 | extern char *pseudo_version; | ||
| 29 | |||
| 30 | -#define PSEUDO_LOCKFILE PSEUDO_DATA "/pseudo.lock" | ||
| 31 | -#define PSEUDO_LOGFILE PSEUDO_DATA "/pseudo.log" | ||
| 32 | -#define PSEUDO_PIDFILE PSEUDO_DATA "/pseudo.pid" | ||
| 33 | -#define PSEUDO_SOCKET PSEUDO_DATA "/pseudo.socket" | ||
| 34 | +#define PSEUDO_LOCKFILE "/pseudo.lock" | ||
| 35 | +#define PSEUDO_LOGFILE "/pseudo.log" | ||
| 36 | +#define PSEUDO_PIDFILE "/pseudo.pid" | ||
| 37 | +#define PSEUDO_SOCKET "/pseudo.socket" | ||
| 38 | + | ||
| 39 | +extern char *pseudo_get_pid(); | ||
| 40 | +extern char *pseudo_get_lockfile(); | ||
| 41 | +extern char *pseudo_get_logfile(); | ||
| 42 | +extern char *pseudo_get_socketfile(); | ||
| 43 | + | ||
| 44 | |||
| 45 | /* some systems might not have *at(). We like to define operations in | ||
| 46 | * terms of each other, and for instance, open(...) is the same as | ||
| 22 | Index: git/pseudo_db.c | 47 | Index: git/pseudo_db.c |
| 23 | =================================================================== | 48 | =================================================================== |
| 24 | --- git.orig/pseudo_db.c 2010-07-23 12:12:21.000000000 +0100 | 49 | --- git.orig/pseudo_db.c 2010-07-24 00:28:35.762423800 +0100 |
| 25 | +++ git/pseudo_db.c 2010-07-23 13:40:21.614745308 +0100 | 50 | +++ git/pseudo_db.c 2010-07-24 00:28:36.282335730 +0100 |
| 26 | @@ -465,17 +465,18 @@ | 51 | @@ -465,17 +465,18 @@ |
| 27 | char *errmsg; | 52 | char *errmsg; |
| 28 | static int registered_cleanup = 0; | 53 | static int registered_cleanup = 0; |
| @@ -46,8 +71,8 @@ Index: git/pseudo_db.c | |||
| 46 | } | 71 | } |
| 47 | Index: git/pseudo_server.c | 72 | Index: git/pseudo_server.c |
| 48 | =================================================================== | 73 | =================================================================== |
| 49 | --- git.orig/pseudo_server.c 2010-07-23 12:12:21.000000000 +0100 | 74 | --- git.orig/pseudo_server.c 2010-07-24 00:28:35.762423800 +0100 |
| 50 | +++ git/pseudo_server.c 2010-07-23 13:36:09.340857158 +0100 | 75 | +++ git/pseudo_server.c 2010-07-24 10:27:59.242335869 +0100 |
| 51 | @@ -107,7 +107,7 @@ | 76 | @@ -107,7 +107,7 @@ |
| 52 | } | 77 | } |
| 53 | 78 | ||
| @@ -57,10 +82,31 @@ Index: git/pseudo_server.c | |||
| 57 | if (!pseudo_path) { | 82 | if (!pseudo_path) { |
| 58 | pseudo_diag("can't find %s directory.\n", PSEUDO_DATA); | 83 | pseudo_diag("can't find %s directory.\n", PSEUDO_DATA); |
| 59 | return 1; | 84 | return 1; |
| 85 | @@ -138,9 +138,9 @@ | ||
| 86 | return 0; | ||
| 87 | } | ||
| 88 | setsid(); | ||
| 89 | - pseudo_path = strdup(PSEUDO_PIDFILE); | ||
| 90 | + pseudo_path = pseudo_get_pid(); | ||
| 91 | if (!pseudo_path) { | ||
| 92 | - pseudo_diag("Couldn't get path for %s\n", PSEUDO_PIDFILE); | ||
| 93 | + pseudo_diag("Couldn't get pid path\n"); | ||
| 94 | return 1; | ||
| 95 | } | ||
| 96 | fp = fopen(pseudo_path, "w"); | ||
| 97 | @@ -156,7 +156,7 @@ | ||
| 98 | pseudo_new_pid(); | ||
| 99 | fclose(stdin); | ||
| 100 | fclose(stdout); | ||
| 101 | - if (!pseudo_logfile(PSEUDO_LOGFILE)) | ||
| 102 | + if (!pseudo_logfile(pseudo_get_logfile())) | ||
| 103 | fclose(stderr); | ||
| 104 | } | ||
| 105 | signal(SIGHUP, quit_now); | ||
| 60 | Index: git/pseudo_util.c | 106 | Index: git/pseudo_util.c |
| 61 | =================================================================== | 107 | =================================================================== |
| 62 | --- git.orig/pseudo_util.c 2010-07-23 12:12:21.000000000 +0100 | 108 | --- git.orig/pseudo_util.c 2010-07-24 00:28:35.962336149 +0100 |
| 63 | +++ git/pseudo_util.c 2010-07-23 13:41:11.062734484 +0100 | 109 | +++ git/pseudo_util.c 2010-07-24 10:50:48.062336358 +0100 |
| 64 | @@ -593,6 +593,50 @@ | 110 | @@ -593,6 +593,50 @@ |
| 65 | return new_environ; | 111 | return new_environ; |
| 66 | } | 112 | } |
| @@ -112,3 +158,171 @@ Index: git/pseudo_util.c | |||
| 112 | /* get the full path to a file under $PSEUDO_PREFIX. Other ways of | 158 | /* get the full path to a file under $PSEUDO_PREFIX. Other ways of |
| 113 | * setting the prefix all set it in the environment. | 159 | * setting the prefix all set it in the environment. |
| 114 | */ | 160 | */ |
| 161 | @@ -691,6 +735,26 @@ | ||
| 162 | return s; | ||
| 163 | } | ||
| 164 | |||
| 165 | +char * | ||
| 166 | +pseudo_get_pid() { | ||
| 167 | + return pseudo_data_path(PSEUDO_PIDFILE); | ||
| 168 | +} | ||
| 169 | + | ||
| 170 | +char * | ||
| 171 | +pseudo_get_lockfile() { | ||
| 172 | + return pseudo_data_path(PSEUDO_LOCKFILE); | ||
| 173 | +} | ||
| 174 | + | ||
| 175 | +char * | ||
| 176 | +pseudo_get_logfile() { | ||
| 177 | + return pseudo_data_path(PSEUDO_LOGFILE); | ||
| 178 | +} | ||
| 179 | + | ||
| 180 | +char * | ||
| 181 | +pseudo_get_socketfile() { | ||
| 182 | + return pseudo_data_path(PSEUDO_SOCKET); | ||
| 183 | +} | ||
| 184 | + | ||
| 185 | /* these functions define the sizes pseudo will try to use | ||
| 186 | * when trying to allocate space, or guess how much space | ||
| 187 | * other people will have allocated; see the GNU man page | ||
| 188 | @@ -844,20 +908,14 @@ | ||
| 189 | |||
| 190 | /* set up a log file */ | ||
| 191 | int | ||
| 192 | -pseudo_logfile(char *defname) { | ||
| 193 | - char *pseudo_path; | ||
| 194 | +pseudo_logfile(char *pseudo_path) { | ||
| 195 | char *filename, *s; | ||
| 196 | extern char *program_invocation_short_name; /* glibcism */ | ||
| 197 | int fd; | ||
| 198 | |||
| 199 | if ((filename = getenv("PSEUDO_DEBUG_FILE")) == NULL) { | ||
| 200 | - if (!defname) { | ||
| 201 | - pseudo_debug(3, "no special log file requested, using stderr.\n"); | ||
| 202 | - return -1; | ||
| 203 | - } | ||
| 204 | - pseudo_path = strdup(defname); | ||
| 205 | if (!pseudo_path) { | ||
| 206 | - pseudo_diag("can't get path for prefix/%s\n", PSEUDO_LOGFILE); | ||
| 207 | + pseudo_debug(3, "no special log file requested or unable to malloc space, using stderr.\n"); | ||
| 208 | return -1; | ||
| 209 | } | ||
| 210 | } else { | ||
| 211 | @@ -903,6 +961,7 @@ | ||
| 212 | len += 8; | ||
| 213 | if (prog) | ||
| 214 | len += strlen(program_invocation_short_name); | ||
| 215 | + free(pseudo_path); | ||
| 216 | pseudo_path = malloc(len); | ||
| 217 | if (!pseudo_path) { | ||
| 218 | pseudo_diag("can't allocate space for debug file name.\n"); | ||
| 219 | Index: git/pseudo.c | ||
| 220 | =================================================================== | ||
| 221 | --- git.orig/pseudo.c 2010-07-24 10:22:10.053594896 +0100 | ||
| 222 | +++ git/pseudo.c 2010-07-24 10:23:20.883585467 +0100 | ||
| 223 | @@ -272,7 +272,7 @@ | ||
| 224 | pseudo_new_pid(); | ||
| 225 | |||
| 226 | pseudo_debug(3, "opening lock.\n"); | ||
| 227 | - lockname = strdup(PSEUDO_LOCKFILE); | ||
| 228 | + lockname = pseudo_get_lockfile(); | ||
| 229 | if (!lockname) { | ||
| 230 | pseudo_diag("Couldn't allocate a file path.\n"); | ||
| 231 | exit(EXIT_FAILURE); | ||
| 232 | Index: git/pseudo_client.c | ||
| 233 | =================================================================== | ||
| 234 | --- git.orig/pseudo_client.c 2010-07-24 10:03:51.933588401 +0100 | ||
| 235 | +++ git/pseudo_client.c 2010-07-24 10:49:22.922336916 +0100 | ||
| 236 | @@ -359,6 +359,7 @@ | ||
| 237 | FILE *fp; | ||
| 238 | extern char **environ; | ||
| 239 | int cwd_fd; | ||
| 240 | + char *pidpath; | ||
| 241 | |||
| 242 | if ((server_pid = fork()) != 0) { | ||
| 243 | if (server_pid == -1) { | ||
| 244 | @@ -383,7 +384,12 @@ | ||
| 245 | pseudo_diag("Couldn't change to server dir [%d]: %s\n", | ||
| 246 | pseudo_dir_fd, strerror(errno)); | ||
| 247 | } | ||
| 248 | - fp = fopen(PSEUDO_PIDFILE, "r"); | ||
| 249 | + pidpath = pseudo_get_pid(); | ||
| 250 | + if (!pidpath) { | ||
| 251 | + pseudo_diag("Couldn't get pid path\n"); | ||
| 252 | + return 1; | ||
| 253 | + } | ||
| 254 | + fp = fopen(pidpath, "r"); | ||
| 255 | if (fchdir(cwd_fd) == -1) { | ||
| 256 | pseudo_diag("return to previous directory failed: %s\n", | ||
| 257 | strerror(errno)); | ||
| 258 | @@ -396,8 +402,9 @@ | ||
| 259 | fclose(fp); | ||
| 260 | } else { | ||
| 261 | pseudo_diag("no pid file (%s): %s\n", | ||
| 262 | - PSEUDO_PIDFILE, strerror(errno)); | ||
| 263 | + pidpath, strerror(errno)); | ||
| 264 | } | ||
| 265 | + free(pidpath); | ||
| 266 | pseudo_debug(2, "read new pid file: %d\n", server_pid); | ||
| 267 | /* at this point, we should have a new server_pid */ | ||
| 268 | return 0; | ||
| 269 | @@ -535,10 +542,19 @@ | ||
| 270 | |||
| 271 | static int | ||
| 272 | client_connect(void) { | ||
| 273 | + char *socketfile = pseudo_get_socketfile(); | ||
| 274 | /* we have a server pid, is it responsive? */ | ||
| 275 | - struct sockaddr_un sun = { AF_UNIX, PSEUDO_SOCKET }; | ||
| 276 | + struct sockaddr_un sun = { AF_UNIX, "" }; | ||
| 277 | int cwd_fd; | ||
| 278 | |||
| 279 | + if (!socketfile) { | ||
| 280 | + pseudo_diag("Couldn't malloc socketfile"); | ||
| 281 | + | ||
| 282 | + return 1; | ||
| 283 | + } | ||
| 284 | + | ||
| 285 | + strncpy(sun.sun_path, socketfile, sizeof(sun.sun_path) - 1); | ||
| 286 | + | ||
| 287 | connect_fd = socket(PF_UNIX, SOCK_STREAM, 0); | ||
| 288 | connect_fd = pseudo_fd(connect_fd, MOVE_FD); | ||
| 289 | if (connect_fd == -1) { | ||
| 290 | @@ -564,7 +580,7 @@ | ||
| 291 | return 1; | ||
| 292 | } | ||
| 293 | if (connect(connect_fd, (struct sockaddr *) &sun, sizeof(sun)) == -1) { | ||
| 294 | - pseudo_debug(3, "can't connect socket to pseudo.socket: (%s)\n", strerror(errno)); | ||
| 295 | + pseudo_debug(3, "can't connect socket to %s: (%s)\n", sun.sun_path, strerror(errno)); | ||
| 296 | close(connect_fd); | ||
| 297 | if (fchdir(cwd_fd) == -1) { | ||
| 298 | pseudo_diag("return to previous directory failed: %s\n", | ||
| 299 | @@ -588,6 +604,7 @@ | ||
| 300 | FILE *fp; | ||
| 301 | server_pid = 0; | ||
| 302 | int cwd_fd; | ||
| 303 | + char *pidpath; | ||
| 304 | |||
| 305 | /* avoid descriptor leak, I hope */ | ||
| 306 | if (connect_fd >= 0) { | ||
| 307 | @@ -604,7 +621,12 @@ | ||
| 308 | return 1; | ||
| 309 | } | ||
| 310 | if (fchdir(pseudo_dir_fd) != 1) { | ||
| 311 | - fp = fopen(PSEUDO_PIDFILE, "r"); | ||
| 312 | + pidpath = pseudo_get_pid(); | ||
| 313 | + if (!pidpath) { | ||
| 314 | + pseudo_diag("Couldn't get pid path\n"); | ||
| 315 | + return 1; | ||
| 316 | + } | ||
| 317 | + fp = fopen(pidpath, "r"); | ||
| 318 | if (fchdir(cwd_fd) == -1) { | ||
| 319 | pseudo_diag("return to previous directory failed: %s\n", | ||
| 320 | strerror(errno)); | ||
| 321 | @@ -619,6 +641,7 @@ | ||
| 322 | pseudo_debug(1, "Opened server PID file, but didn't get a pid.\n"); | ||
| 323 | } | ||
| 324 | fclose(fp); | ||
| 325 | + free(pidpath); | ||
| 326 | } | ||
| 327 | if (server_pid) { | ||
| 328 | if (kill(server_pid, 0) == -1) { | ||
diff --git a/meta/packages/pseudo/pseudo_git.bb b/meta/packages/pseudo/pseudo_git.bb index e675cbcade..a06e87ac9c 100644 --- a/meta/packages/pseudo/pseudo_git.bb +++ b/meta/packages/pseudo/pseudo_git.bb | |||
| @@ -6,7 +6,7 @@ LICENSE = "LGPL2.1" | |||
| 6 | DEPENDS = "sqlite3" | 6 | DEPENDS = "sqlite3" |
| 7 | 7 | ||
| 8 | PV = "0.0+git${SRCPV}" | 8 | PV = "0.0+git${SRCPV}" |
| 9 | PR = "r6" | 9 | PR = "r7" |
| 10 | 10 | ||
| 11 | SRC_URI = "git://github.com/wrpseudo/pseudo.git;protocol=git \ | 11 | SRC_URI = "git://github.com/wrpseudo/pseudo.git;protocol=git \ |
| 12 | file://tweakflags.patch \ | 12 | file://tweakflags.patch \ |
