Skip to content

Commit aab2c2b

Browse files
committed
win32/sendmail.c/MailConnect(): move socket creation
1 parent 04c96de commit aab2c2b

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

win32/sendmail.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -738,21 +738,14 @@ static int MailConnect()
738738
return 0;
739739
#endif
740740

741-
/* Create Socket */
742-
if ((PW32G(mail_socket) = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
743-
return (FAILED_TO_OBTAIN_SOCKET_HANDLE);
744-
}
745-
746741
/* Get our own host name */
747742
if (gethostname(PW32G(mail_local_host), HOST_NAME_LEN)) {
748-
closesocket(PW32G(mail_socket));
749743
return (FAILED_TO_GET_HOSTNAME);
750744
}
751745

752746
ent = gethostbyname(PW32G(mail_local_host));
753747

754748
if (!ent) {
755-
closesocket(PW32G(mail_socket));
756749
return (FAILED_TO_GET_HOSTNAME);
757750
}
758751

@@ -765,7 +758,6 @@ return 0;
765758
#endif
766759
{
767760
if (namelen + 2 >= HOST_NAME_LEN) {
768-
closesocket(PW32G(mail_socket));
769761
return (FAILED_TO_GET_HOSTNAME);
770762
}
771763

@@ -774,13 +766,17 @@ return 0;
774766
strcpy(PW32G(mail_local_host) + namelen + 1, "]");
775767
} else {
776768
if (namelen >= HOST_NAME_LEN) {
777-
closesocket(PW32G(mail_socket));
778769
return (FAILED_TO_GET_HOSTNAME);
779770
}
780771

781772
strcpy(PW32G(mail_local_host), ent->h_name);
782773
}
783774

775+
/* Create Socket */
776+
if ((PW32G(mail_socket) = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
777+
return (FAILED_TO_OBTAIN_SOCKET_HANDLE);
778+
}
779+
784780
/* Resolve the servers IP */
785781
unsigned long server_addr = GetAddr(PW32G(mail_host));
786782

0 commit comments

Comments
 (0)