Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into localtime_r
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ortmann committed Jan 10, 2024
2 parents 5730200 + bf2c80b commit 1c3a79a
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 173 deletions.
9 changes: 1 addition & 8 deletions doc/sphinx_source/modules/mod/transfer.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Last revised: January 1, 2002
Last revised: November 29, 2023

.. _transfer:

Expand Down Expand Up @@ -27,13 +27,6 @@ There are also some variables you can set in your config file:
but admits that may be too small. 1024 is standard these days.
Set this to 0 to use turbo-dcc (recommended).

set copy-to-tmp 1
Enable this setting if you want to copy files to a temporary location
before sending or receiving them. This might be useful for file
stability, but if your directories are NFS mounted, it's a pain.
Setting this to 1 is not advised for big files or if you're low on
disk space.

set xfer-timeout 30
Set here the time (in seconds) to wait before an inactive transfer
times out.
Expand Down
5 changes: 2 additions & 3 deletions doc/sphinx_source/using/tcl-commands.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. highlight:: text

Eggdrop Tcl Commands
Last revised: January 24, 2021
Last revised: January 6, 2024

====================
Eggdrop Tcl Commands
Expand Down Expand Up @@ -2011,8 +2011,7 @@ dccsend <filename> <ircnick>
| 4 | the file was queued for later transfer, which means that person has |
| | too many file transfers going right now |
+-------+---------------------------------------------------------------------+
| 5 | copy-to-tmp is enabled and the file already exists in the temp |
| | directory |
| 5 | the file could not be opened or temporary file could not be created |
+-------+---------------------------------------------------------------------+

Module: transfer
Expand Down
6 changes: 0 additions & 6 deletions eggdrop.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1445,12 +1445,6 @@ set max-dloads 3
# 0 is turbo-dcc (recommended).
set dcc-block 0

# Enable this setting if you want to copy files to a temporary location before
# sending or receiving them. This might be useful for file stability, but if
# your directories are NFS mounted, it's a pain. Setting this to 1 is not
# advised for big files or if you're low on disk space.
set copy-to-tmp 1

# Set here the time (in seconds) to wait before an inactive transfer times out.
set xfer-timeout 30

Expand Down
4 changes: 2 additions & 2 deletions src/dccutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "tandem.h"

extern struct dcc_t *dcc;
extern int dcc_total, dcc_flood_thr, backgrd, copy_to_tmp, max_socks;
extern int dcc_total, dcc_flood_thr, backgrd, max_socks;
extern char botnetnick[], version[];
extern time_t now;
extern sock_list *socklist;
Expand Down Expand Up @@ -318,7 +318,7 @@ void killtransfer(int n)
fclose(dcc[n].u.xfer->f);
dcc[n].u.xfer->f = NULL;
}
if (dcc[n].u.xfer->filename && copy_to_tmp) {
if (dcc[n].u.xfer->filename) {
for (i = 0; i < dcc_total; i++) {
if ((i != n) && (dcc[i].type->flags & DCT_FILETRAN) &&
(dcc[i].u.xfer->filename) &&
Expand Down
8 changes: 0 additions & 8 deletions src/eggdrop.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,6 @@
#define nrealloc(x,y) n_realloc((x),(y),__FILE__,__LINE__)
#define nfree(x) n_free((x),__FILE__,__LINE__)

#ifdef DEBUG_CONTEXT
# define Context eggContext(__FILE__, __LINE__, NULL)
# define ContextNote(note) eggContextNote(__FILE__, __LINE__, NULL, note)
#else
# define Context do {} while (0)
# define ContextNote(note) do {} while (0)
#endif

#ifdef DEBUG_ASSERT
# define Assert(expr) do { \
if (!(expr)) \
Expand Down
81 changes: 14 additions & 67 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/

/* We need config.h for CYGWIN_HACKS, but windows.h must be included before
* eggdrop headers, because the malloc/free/Context macros break the inclusion.
* eggdrop headers, because the malloc/free macros break the inclusion.
* The SSL undefs are a workaround for bug #2182 in openssl with msys/mingw.
*/
#include <config.h>
Expand Down Expand Up @@ -166,11 +166,7 @@ unsigned long itraffic_unknown = 0;
unsigned long itraffic_unknown_today = 0;

#ifdef DEBUG_CONTEXT
/* Context storage for fatal crashes */
char cx_file[16][32];
char cx_note[16][256];
int cx_line[16];
int cx_ptr = 0;
extern char last_bind_called[];
#endif

#ifdef TLS
Expand Down Expand Up @@ -255,31 +251,25 @@ static void write_debug()
{
int x;
char s[26];
int y;

if (nested_debug) {
/* Yoicks, if we have this there's serious trouble!
* All of these are pretty reliable, so we'll try these.
*
* NOTE: don't try and display context-notes in here, it's
* _not_ safe <cybah>
*/
x = creat("DEBUG.DEBUG", 0644);
if (x >= 0) {
setsock(x, SOCK_NONSOCK);
ctime_r(&now, s);
dprintf(-x, "Debug (%s) written %s", ver, s);
dprintf(-x, "Please report problem to https://github.com/eggheads/eggdrop/issues\n");
dprintf(-x, "Debug (%s) written %s\n"
"Please report problem to https://github.com/eggheads/eggdrop/issues\n"
"Check doc/BUG-REPORT on how to do so.", ver, s);
#ifdef EGG_PATCH
dprintf(-x, "Patch level: %s\n", EGG_PATCH);
#else
dprintf(-x, "Patch level: %s\n", "stable");
#endif
dprintf(-x, "Context: ");
cx_ptr = cx_ptr & 15;
for (y = ((cx_ptr + 1) & 15); y != cx_ptr; y = ((y + 1) & 15))
dprintf(-x, "%s/%d,\n ", cx_file[y], cx_line[y]);
dprintf(-x, "%s/%d\n\n", cx_file[y], cx_line[y]);
if (*last_bind_called)
dprintf(-x, "Last bind (may not be related): %s\n", last_bind_called);
killsock(x);
close(x);
}
Expand All @@ -288,10 +278,10 @@ static void write_debug()
* have caused the fault last time. */
} else
nested_debug = 1;
putlog(LOG_MISC, "*", "* Last context: %s/%d [%s]", cx_file[cx_ptr],
cx_line[cx_ptr], cx_note[cx_ptr][0] ? cx_note[cx_ptr] : "");
putlog(LOG_MISC, "*", "* Please REPORT this BUG!");
putlog(LOG_MISC, "*", "* Please report problem to https://github.com/eggheads/eggdrop/issues");
putlog(LOG_MISC, "*", "* Check doc/BUG-REPORT on how to do so.");
if (*last_bind_called)
putlog(LOG_MISC, "*", "* Last bind (may not be related): %s", last_bind_called);
x = creat("DEBUG", 0644);
setsock(x, SOCK_NONSOCK);
if (x < 0) {
Expand Down Expand Up @@ -347,14 +337,7 @@ static void write_debug()
#ifdef STRIPFLAGS
dprintf(-x, "Strip flags: %s\n", STRIPFLAGS);
#endif

dprintf(-x, "Context: ");
cx_ptr = cx_ptr & 15;
for (y = ((cx_ptr + 1) & 15); y != cx_ptr; y = ((y + 1) & 15))
dprintf(-x, "%s/%d, [%s]\n ", cx_file[y], cx_line[y],
(cx_note[y][0]) ? cx_note[y] : "");
dprintf(-x, "%s/%d [%s]\n\n", cx_file[cx_ptr], cx_line[cx_ptr],
(cx_note[cx_ptr][0]) ? cx_note[cx_ptr] : "");
dprintf(-x, "Last bind (may not be related): %s\n", last_bind_called);
tell_dcc(-x);
dprintf(-x, "\n");
debug_mem_to_dcc(-x);
Expand Down Expand Up @@ -439,40 +422,12 @@ static void got_ill(int z)
{
check_tcl_signal("sigill");
#ifdef DEBUG_CONTEXT
putlog(LOG_MISC, "*", "* Context: %s/%d [%s]", cx_file[cx_ptr],
cx_line[cx_ptr], (cx_note[cx_ptr][0]) ? cx_note[cx_ptr] : "");
putlog(LOG_MISC, "*", "* Please REPORT this BUG!");
putlog(LOG_MISC, "*", "* Check doc/BUG-REPORT on how to do so.");
putlog(LOG_MISC, "*", "* Last bind (may not be related): %s", last_bind_called);
#endif
}

#ifdef DEBUG_CONTEXT
/* Called from the Context macro.
*/
void eggContext(const char *file, int line, const char *module)
{
eggContextNote(file, line, module, NULL);
}

/* Called from the ContextNote macro.
*/
void eggContextNote(const char *file, int line, const char *module,
const char *note)
{
char *p;

p = strrchr(file, '/');
cx_ptr = ((cx_ptr + 1) & 15);
if (!module)
strlcpy(cx_file[cx_ptr], p ? p + 1 : file, sizeof cx_file[cx_ptr]);
else
snprintf(cx_file[cx_ptr], sizeof cx_file[cx_ptr], "%s:%s", module, p ? p + 1 : file);
cx_line[cx_ptr] = line;
if (!note)
cx_note[cx_ptr][0] = 0;
else
strlcpy(cx_note[cx_ptr], note, sizeof cx_note[cx_ptr]);
}
#endif /* DEBUG_CONTEXT */

#ifdef DEBUG_ASSERT
/* Called from the Assert macro.
*/
Expand Down Expand Up @@ -604,8 +559,6 @@ static time_t then;
static struct tm nowtm;

/* Called once a second.
*
* Note: Try to not put any Context lines in here (guppy 21Mar2000).
*/
static void core_secondly()
{
Expand Down Expand Up @@ -1027,12 +980,6 @@ int main(int arg_c, char **arg_v)
setrlimit(RLIMIT_CORE, &cdlim);
#endif

#ifdef DEBUG_CONTEXT
/* Initialise context list */
for (i = 0; i < 16; i++)
Context;
#endif

argc = arg_c;
argv = arg_v;

Expand Down
1 change: 1 addition & 0 deletions src/mod/filesys.mod/filesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ static void filesys_dcc_send_hostresolved(int i)
/* Put uploads in a temp file first */
dcc[i].u.xfer->f = tmpfile();
if (dcc[i].u.xfer->f == NULL) {
debug1("filesys: filesys_dcc_send_hostresolved(): tmpfile(): error: %s", strerror(errno));
dprintf(DP_HELP,
"NOTICE %s :Can't create file `%s' (temp dir error)\n",
dcc[i].nick, dcc[i].u.xfer->origname);
Expand Down
12 changes: 2 additions & 10 deletions src/mod/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ typedef void (*chanout_butfunc)(int, int, const char *, ...) ATTRIBUTE_FORMAT(pr
/* 0 - 3 */
#define nmalloc(x) (((void *(*)())global[0])((x),MODULE_NAME,__FILE__,__LINE__))
#define nfree(x) (global[1]((x),MODULE_NAME,__FILE__,__LINE__))
#ifdef DEBUG_CONTEXT
# define Context (global[2](__FILE__, __LINE__, MODULE_NAME))
#else
# define Context do {} while (0)
#endif
#define Context do {} while (0) /* For backward compatibility only */
#define module_rename ((int (*)(char *, char *))global[3])
/* 4 - 7 */
#define module_register ((int (*)(char *, Function *, int, int))global[4])
Expand Down Expand Up @@ -396,11 +392,7 @@ typedef void (*chanout_butfunc)(int, int, const char *, ...) ATTRIBUTE_FORMAT(pr
#define nrealloc(x,y) (((void *(*)())global[230])((x),(y),MODULE_NAME,__FILE__,__LINE__))
#define xtra_set ((int(*)(struct userrec *,struct user_entry *, void *))global[231])
/* 232 - 235 */
#ifdef DEBUG_CONTEXT
# define ContextNote(note) (global[232](__FILE__, __LINE__, MODULE_NAME, note))
#else
# define ContextNote(note) do {} while (0)
#endif
#define ContextNote(note) do {} while (0) /* For backward compatibility only */
#ifdef DEBUG_ASSERT
# define Assert(expr) do { \
if (!(expr)) \
Expand Down
9 changes: 4 additions & 5 deletions src/mod/share.mod/share.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define MODULE_NAME "share"
#define MAKING_SHARE

#include <errno.h>
#include "src/mod/module.h"

#include <netinet/in.h>
Expand Down Expand Up @@ -1242,12 +1243,10 @@ static void share_ufsend(int idx, char *par)
putlog(LOG_MISC, "*", "NO MORE DCC CONNECTIONS -- can't grab userfile");
dprintf(idx, "s e I can't open a DCC to you; I'm full.\n");
zapfbot(idx);
} else if (copy_to_tmp && !(f = tmpfile())) {
} else if (!(f = tmpfile())) {
debug1("share: share_ufsend(): tmpfile(): error: %s", strerror(errno));
putlog(LOG_MISC, "*", "CAN'T WRITE TEMPORARY USERFILE DOWNLOAD FILE!");
zapfbot(idx);
} else if (!copy_to_tmp && !(f = fopen(s, "wb"))) {
putlog(LOG_MISC, "*", "CAN'T WRITE USERFILE DOWNLOAD FILE!");
zapfbot(idx);
} else {
/* Ignore longip and use botaddr, arg kept for backward compat for pre 1.8.3 */
newsplit(&par);
Expand Down Expand Up @@ -2353,7 +2352,7 @@ char *share_start(Function *global_funcs)

global = global_funcs;

module_register(MODULE_NAME, share_table, 2, 4);
module_register(MODULE_NAME, share_table, 2, 5);
if (!module_depend(MODULE_NAME, "eggdrop", 108, 0)) {
module_undepend(MODULE_NAME);
return "This module requires Eggdrop 1.8.0 or later.";
Expand Down
7 changes: 0 additions & 7 deletions src/mod/transfer.mod/help/set/transfer.help
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
mode, the bot will dump transfers as fast as possible, only
stopping to count acks after it's finished. This can dramatically
improve the speed of file transfers, and is recommended.
%{help=set copy-to-tmp}%{+n}
### %bset copy-to-tmp%b <0/1>
Enable this setting if you want to copy files to a temporary location
before sending or receiving them. This might be useful for file
stability, but if your directories are NFS mounted, it's a pain.
Setting this to 1 is not advised for big files or if you're low on
disk space.
%{help=set xfer-timeout}%{+n}
### %bset xfer-timeout%b <#>
This is the number of seconds to wait before a dcc send or get is
Expand Down
4 changes: 2 additions & 2 deletions src/mod/transfer.mod/help/transfer.help
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
support for userfile sharing.

Config file variables for configuring the transfer module:
%bxfer-timeout copy-to-tmp dcc-block%b
%bmax-dloads sharefail-unlink%b
%bxfer-timeout dcc-block max-dloads%b
%bsharefail-unlink%b
(Use %b'.help set <variable>'%b for more info)
30 changes: 14 additions & 16 deletions src/mod/transfer.mod/transfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ static void eof_dcc_send(int idx)
+ strlen(dcc[idx].u.xfer->origname) + 1);
sprintf(nfn, "%s%s", dcc[idx].u.xfer->dir, dcc[idx].u.xfer->origname);

if (copy_to_tmp && (l = fcopyfile(dcc[idx].u.xfer->f, nfn))) {
if ((l = fcopyfile(dcc[idx].u.xfer->f, nfn))) {
putlog(LOG_MISC | LOG_FILES, "*", TRANSFER_FAILED_MOVE, nfn);
}
/* Only close now in case it was a tmpfile, as it's deleted upon close */
Expand All @@ -302,8 +302,8 @@ static void eof_dcc_send(int idx)
u = get_user_by_host(s);
hand = u ? u->handle : "*";

/* Add to file database if not tmpfile or if copyfile succeeded */
if (!copy_to_tmp || !l) {
/* Add to file database if copyfile succeeded */
if (!l) {
module_entry *fs = module_find("filesys", 0, 0);

if (fs != NULL) {
Expand Down Expand Up @@ -961,8 +961,10 @@ static int raw_dcc_resend_send(char *filename, char *nick, char *from,

zz = -1;
f = fopen(filename, "r");
if (!f)
if (!f) {
debug2("transfer: raw_dcc_resend_send(): fopen(%s): error: %s", filename, strerror(errno));
return DCCSEND_BADFN;
}
fseeko(f, 0, SEEK_END);
dccfilesize = ftello(f);
fclose(f);
Expand All @@ -988,19 +990,15 @@ static int raw_dcc_resend_send(char *filename, char *nick, char *from,
else
nfn++;

if (copy_to_tmp) {
f = tmpfile();
if (!f)
return DCCSEND_BADFN;
if (copyfilef(filename, f)) {
fclose(f);
return DCCSEND_FCOPY;
}
} else
f = fopen(filename, "r");

if (!f)
f = tmpfile();
if (!f) {
debug1("transfer: raw_dcc_resend_send(): tmpfile(): error: %s", strerror(errno));
return DCCSEND_BADFN;
}
if (copyfilef(filename, f)) {
fclose(f);
return DCCSEND_FCOPY;
}

if ((i = new_dcc(&DCC_GET_PENDING, sizeof(struct xfer_info))) == -1) {
fclose(f);
Expand Down
Loading

0 comments on commit 1c3a79a

Please sign in to comment.