Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) Add debug detail log for fopen() and tmpfile() #1504

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/mod/share.mod/share.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "src/mod/module.h"

#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -1244,9 +1245,11 @@ static void share_ufsend(int idx, char *par)
zapfbot(idx);
} else if (copy_to_tmp && !(f = tmpfile())) {
putlog(LOG_MISC, "*", "CAN'T WRITE TEMPORARY USERFILE DOWNLOAD FILE!");
debug1("share: tmpfile(): %s", strerror(errno));
zapfbot(idx);
} else if (!copy_to_tmp && !(f = fopen(s, "wb"))) {
putlog(LOG_MISC, "*", "CAN'T WRITE USERFILE DOWNLOAD FILE!");
debug2("share: fopen(%s): %s", s, strerror(errno));
zapfbot(idx);
} else {
/* Ignore longip and use botaddr, arg kept for backward compat for pre 1.8.3 */
Expand Down
12 changes: 7 additions & 5 deletions src/users.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include "main.h"
#include "users.h"
#include "chan.h"
#include "modules.h"
#include "tandem.h"

#include <netinet/in.h>
#include <arpa/inet.h>

extern struct dcc_t *dcc;
extern struct userrec *userlist, *lastuser;
extern struct chanset_t *chanset;
Expand Down Expand Up @@ -698,9 +699,10 @@ int readuserfile(char *file, struct userrec **ret)
global_invites = NULL;
}
lasthand[0] = 0;
f = fopen(file, "r");
if (f == NULL)
if (!(f = fopen(file, "r"))) {
debug2("users: fopen(%s): %s", file, strerror(errno));
return 0;
}
noshare = noxtra = 1;
/* read opening comment */
s = buf;
Expand Down