[w3m-dev 03632] cleanup (don't close connection of news server)

* file.c (loadSomething): remove UFclose nntp:,news:
	(loadFile): UFclose
	(loadGeneralFile): always UFclose
* html.h (UFclose): only reset when ISclose ==0
* istream.c (ISclose): return int
	(ISfileno): flag IST_UNCLOSE
* istream.h (ISclose): return int
	(IST_UNCLOSE): added
* news.c (news_close): reset IST_UNCLOSE
	(news_open): set IST_UNCLOSE
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
This commit is contained in:
Fumitoshi UKAI
2003-01-10 17:06:17 +00:00
parent dfc317f6ab
commit f4d6305bdd
6 changed files with 38 additions and 21 deletions
+15 -1
View File
@@ -1,3 +1,17 @@
2003-01-11 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 03632] cleanup (don't close connection of news server)
* file.c (loadSomething): remove UFclose nntp:,news:
(loadFile): UFclose
(loadGeneralFile): always UFclose
* html.h (UFclose): only reset when ISclose ==0
* istream.c (ISclose): return int
(ISfileno): flag IST_UNCLOSE
* istream.h (ISclose): return int
(IST_UNCLOSE): added
* news.c (news_close): reset IST_UNCLOSE
(news_open): set IST_UNCLOSE
2003-01-11 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> 2003-01-11 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 03631] display current form item * [w3m-dev 03631] display current form item
@@ -6335,4 +6349,4 @@ a * [w3m-dev 03276] compile error on EWS4800
* release-0-2-1 * release-0-2-1
* import w3m-0.2.1 * import w3m-0.2.1
$Id: ChangeLog,v 1.670 2003/01/10 16:58:30 ukai Exp $ $Id: ChangeLog,v 1.671 2003/01/10 17:06:17 ukai Exp $
+8 -10
View File
@@ -1,4 +1,4 @@
/* $Id: file.c,v 1.182 2003/01/10 16:42:29 ukai Exp $ */ /* $Id: file.c,v 1.183 2003/01/10 17:06:20 ukai Exp $ */
#include "fm.h" #include "fm.h"
#include <sys/types.h> #include <sys/types.h>
#include "myctype.h" #include "myctype.h"
@@ -225,8 +225,6 @@ loadSomething(URLFile *f,
buf->real_scheme = f->scheme; buf->real_scheme = f->scheme;
if (f->scheme == SCM_LOCAL && buf->sourcefile == NULL) if (f->scheme == SCM_LOCAL && buf->sourcefile == NULL)
buf->sourcefile = path; buf->sourcefile = path;
if (f->scheme != SCM_NNTP && f->scheme != SCM_NEWS)
UFclose(f);
return buf; return buf;
} }
@@ -485,7 +483,9 @@ loadFile(char *path)
#ifdef JP_CHARSET #ifdef JP_CHARSET
content_charset = '\0'; content_charset = '\0';
#endif #endif
return loadSomething(&uf, path, loadBuffer, buf); buf = loadSomething(&uf, path, loadBuffer, buf);
UFclose(&uf);
return buf;
} }
int int
@@ -1942,7 +1942,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
doFileSave(f, file); doFileSave(f, file);
if (f.scheme == SCM_FTP) if (f.scheme == SCM_FTP)
FTPhalfclose(f.stream); FTPhalfclose(f.stream);
else if (f.scheme != SCM_NNTP && f.scheme != SCM_NEWS) else
UFclose(&f); UFclose(&f);
return NO_BUFFER; return NO_BUFFER;
} }
@@ -2004,8 +2004,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
if (b->currentURL.host == NULL && b->currentURL.file == NULL) if (b->currentURL.host == NULL && b->currentURL.file == NULL)
copyParsedURL(&b->currentURL, &pu); copyParsedURL(&b->currentURL, &pu);
} }
if (f.scheme != SCM_NNTP && f.scheme != SCM_NEWS) UFclose(&f);
UFclose(&f);
if (fmInitialized) if (fmInitialized)
term_raw(); term_raw();
signal(SIGINT, prevtrap); signal(SIGINT, prevtrap);
@@ -2027,7 +2026,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
doFileSave(f, guess_save_name(t_buf, pu.file)); doFileSave(f, guess_save_name(t_buf, pu.file));
if (f.scheme == SCM_FTP) if (f.scheme == SCM_FTP)
FTPhalfclose(f.stream); FTPhalfclose(f.stream);
else if (f.scheme != SCM_NNTP && f.scheme != SCM_NEWS) else
UFclose(&f); UFclose(&f);
} }
return NO_BUFFER; return NO_BUFFER;
@@ -2045,9 +2044,8 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
#endif #endif
frame_source = flag & RG_FRAME_SRC; frame_source = flag & RG_FRAME_SRC;
b = loadSomething(&f, pu.real_file ? pu.real_file : pu.file, proc, t_buf); b = loadSomething(&f, pu.real_file ? pu.real_file : pu.file, proc, t_buf);
UFclose(&f);
frame_source = 0; frame_source = 0;
if (f.scheme != SCM_NNTP && f.scheme != SCM_NEWS)
UFclose(&f);
if (b) { if (b) {
b->real_scheme = f.scheme; b->real_scheme = f.scheme;
b->real_type = real_type; b->real_type = real_type;
+2 -2
View File
@@ -1,4 +1,4 @@
/* $Id: html.h,v 1.19 2003/01/08 17:24:12 ukai Exp $ */ /* $Id: html.h,v 1.20 2003/01/10 17:06:23 ukai Exp $ */
#ifndef _HTML_H #ifndef _HTML_H
#define _HTML_H #define _HTML_H
#ifdef USE_SSL #ifdef USE_SSL
@@ -14,7 +14,7 @@
#define UFgetc(f) ISgetc((f)->stream) #define UFgetc(f) ISgetc((f)->stream)
#define UFundogetc(f) ISundogetc((f)->stream) #define UFundogetc(f) ISundogetc((f)->stream)
#define UFread(f,buf,len) ISread((f)->stream,buf,len) #define UFread(f,buf,len) ISread((f)->stream,buf,len)
#define UFclose(f) (ISclose((f)->stream), (f)->stream = NULL) #define UFclose(f) (ISclose((f)->stream) == 0 && ((f)->stream = NULL))
struct cmdtable { struct cmdtable {
char *cmdname; char *cmdname;
+7 -5
View File
@@ -1,4 +1,4 @@
/* $Id: istream.c,v 1.17 2003/01/10 16:58:31 ukai Exp $ */ /* $Id: istream.c,v 1.18 2003/01/10 17:06:23 ukai Exp $ */
#include "fm.h" #include "fm.h"
#include "myctype.h" #include "myctype.h"
#include "istream.h" #include "istream.h"
@@ -176,15 +176,17 @@ newEncodedStream(InputStream is, char encoding)
return stream; return stream;
} }
void int
ISclose(InputStream stream) ISclose(InputStream stream)
{ {
MySignalHandler(*prevtrap) (); MySignalHandler(*prevtrap) ();
if (stream == NULL || stream->base.close == NULL) if (stream == NULL || stream->base.close == NULL ||
return; stream->base.type & IST_UNCLOSE)
return -1;
prevtrap = signal(SIGINT, SIG_IGN); prevtrap = signal(SIGINT, SIG_IGN);
stream->base.close(stream->base.handle); stream->base.close(stream->base.handle);
signal(SIGINT, prevtrap); signal(SIGINT, prevtrap);
return 0;
} }
int int
@@ -336,7 +338,7 @@ ISfileno(InputStream stream)
{ {
if (stream == NULL) if (stream == NULL)
return -1; return -1;
switch (IStype(stream)) { switch (IStype(stream) & ~IST_UNCLOSE) {
case IST_BASIC: case IST_BASIC:
return *(int *)stream->base.handle; return *(int *)stream->base.handle;
case IST_FILE: case IST_FILE:
+3 -2
View File
@@ -1,4 +1,4 @@
/* $Id: istream.h,v 1.9 2002/09/28 16:30:07 ukai Exp $ */ /* $Id: istream.h,v 1.10 2003/01/10 17:06:24 ukai Exp $ */
#ifndef IO_STREAM_H #ifndef IO_STREAM_H
#define IO_STREAM_H #define IO_STREAM_H
@@ -116,7 +116,7 @@ extern InputStream newStrStream(Str s);
extern InputStream newSSLStream(SSL * ssl, int sock); extern InputStream newSSLStream(SSL * ssl, int sock);
#endif #endif
extern InputStream newEncodedStream(InputStream is, char encoding); extern InputStream newEncodedStream(InputStream is, char encoding);
extern void ISclose(InputStream stream); extern int ISclose(InputStream stream);
extern int ISgetc(InputStream stream); extern int ISgetc(InputStream stream);
extern int ISundogetc(InputStream stream); extern int ISundogetc(InputStream stream);
extern Str StrISgets(InputStream stream); extern Str StrISgets(InputStream stream);
@@ -134,6 +134,7 @@ extern Str ssl_get_certificate(SSL *ssl, char *hostname);
#define IST_STR 2 #define IST_STR 2
#define IST_SSL 3 #define IST_SSL 3
#define IST_ENCODED 4 #define IST_ENCODED 4
#define IST_UNCLOSE 0x10
#define IStype(stream) ((stream)->base.type) #define IStype(stream) ((stream)->base.type)
#define is_eos(stream) ISeos(stream) #define is_eos(stream) ISeos(stream)
+3 -1
View File
@@ -1,4 +1,4 @@
/* $Id: news.c,v 1.10 2003/01/07 15:56:41 ukai Exp $ */ /* $Id: news.c,v 1.11 2003/01/10 17:06:25 ukai Exp $ */
#include "fm.h" #include "fm.h"
#include "myctype.h" #include "myctype.h"
#include <stdio.h> #include <stdio.h>
@@ -58,6 +58,7 @@ news_close(News * news)
if (!news->host) if (!news->host)
return; return;
if (news->rf) { if (news->rf) {
IStype(news->rf) &= ~IST_UNCLOSE;
ISclose(news->rf); ISclose(news->rf);
news->rf = NULL; news->rf = NULL;
} }
@@ -80,6 +81,7 @@ news_open(News * news)
news->wf = fdopen(dup(sock), "wb"); news->wf = fdopen(dup(sock), "wb");
if (!news->rf || !news->wf) if (!news->rf || !news->wf)
goto open_err; goto open_err;
IStype(news->rf) |= IST_UNCLOSE;
news_command(news, NULL, &status); news_command(news, NULL, &status);
if (status != 200 && status != 201) if (status != 200 && status != 201)
goto open_err; goto open_err;