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

HPCC-30377 SendEmail exception while reading from mail server #17832

Merged
merged 1 commit into from
Nov 9, 2023

Conversation

mckellyln
Copy link
Contributor

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change improves the code (refactor or other change that does not change the functionality)
  • This change fixes warnings (the fix does not alter the functionality or the generated code)
  • This change is a breaking change (fix or feature that will cause existing behavior to change).
  • This change alters the query API (existing queries will have to be recompiled)

Checklist:

  • My code follows the code style of this project.
    • My code does not create any new warnings from compiler, build system, or lint.
  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit is signed.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the CONTRIBUTORS document.
  • The change has been fully tested:
    • I have added tests to cover my changes.
    • All new and existing tests passed.
    • I have checked that this change does not introduce memory leaks.
    • I have used Valgrind or similar tools to check for potential issues.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Cloud-compatibility
    • Premature optimization
    • Existing deployed queries will not be broken
    • This change fixes the problem, not just the symptom
    • The target branch of this pull request is appropriate for such a change.
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised JIRA issues to address them separately
  • This is a user interface / front-end modification
    • I have tested my changes in multiple modern browsers
    • The component(s) render as expected

Smoketest:

  • Send notifications about my Pull Request position in Smoketest queue.
  • Test my draft Pull Request.

Testing:

Manual testing of same code.

@github-actions
Copy link

@mckellyln mckellyln requested a review from ghalliday September 28, 2023 13:00
Copy link
Member

@ghalliday ghalliday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mckellyln a few comments, particularly concerned about backward compatibility.

common/remote/rmtsmtp.cpp Show resolved Hide resolved
@mckellyln mckellyln force-pushed the hpcc-30377 branch 2 times, most recently from eacd995 to c641cd4 Compare October 25, 2023 13:41
@mckellyln mckellyln force-pushed the hpcc-30377 branch 3 times, most recently from b7c2dd8 to 2d4d669 Compare November 2, 2023 13:03
@mckellyln mckellyln requested a review from ghalliday November 2, 2023 13:05
Copy link
Member

@ghalliday ghalliday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mckellyln looks good. A few very minor comments.

ForEachItemIn(i,warnings)
WUmessage(ctx, SeverityWarning, "SendEmail", warnings.item(i));
}

FILESERVICES_API void FILESERVICES_CALL fsSendEmail_v2(ICodeContext * ctx, const char * to, const char * subject, const char * body, const char * mailServer, unsigned port, const char * sender, const char *cc, const char *bcc, bool highPriority)
{
StringArray warnings;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly better to call on to v3 to avoid duplicated code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, changed

@@ -20,8 +20,8 @@ RETURN MODULE
* @param highPriority Optional; if true, message is sent with high priority. Defaults to false (normal priority).
*/

EXPORT SendEmail(varstring to, varstring subject, varstring body, varstring mailServer=GETENV('SMTPserver'), unsigned4 port=(unsigned4) GETENV('SMTPport', '25'), varstring sender=GETENV('emailSenderAddress'), varstring cc='', varstring bcc='', boolean highPriority=false) :=
lib_fileservices.FileServices.SendEmail(to, subject, body, mailServer, port, sender, cc, bcc, highPriority);
EXPORT SendEmail(varstring to, varstring subject, varstring body, varstring mailServer=GETENV('SMTPserver'), unsigned4 port=(unsigned4) GETENV('SMTPport', '25'), varstring sender=GETENV('emailSenderAddress'), varstring cc='', varstring bcc='', boolean highPriority=false, boolean termJobOnFail=true) :=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

picky: This parameter name isn't quite right - because it may not terminate the job. It is more like "reportFailuresAsErrors". (Raising because it is something the ECL user sees.) It doesn't need renaming elsewhere. The new parameter also needs to be included in the comment block above. Same for the other functions in here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, yes, changed.

@@ -545,30 +557,34 @@ class CMailInfo
}
}

void read()
bool read(int keepTrying)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming: Clearer if this was called numRetriesRemaining or something. keepTrying suggests a boolean parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. It is used sort of as a boolean in this func, so I named it that way. But happy to change it.

common/remote/rmtsmtp.cpp Show resolved Hide resolved

bool ok;
int retries = 2;
while (retries >= 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be commoned up unto a function for the common case

info.writeAndRead(buffer, len, numretries)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, yes, cleaner code.

@@ -773,77 +800,138 @@ static const char *quit="QUIT\r\n";

static void doSendEmail(CMailInfo & info, CMailPart const & part)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really a change for now, but this would make much more sense as a member function of CMailInfo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree.

@mckellyln
Copy link
Contributor Author

@ghalliday updates in commit 2. One question back about dropped info.

@mckellyln mckellyln requested a review from ghalliday November 2, 2023 17:30
Copy link
Member

@ghalliday ghalliday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Adding Dan to double check because he has some familiarity with this code.

common/remote/rmtsmtp.cpp Show resolved Hide resolved
@ghalliday ghalliday requested a review from dcamper November 6, 2023 16:57
@ghalliday
Copy link
Member

@dcamper please can you sanity check these changes.

Copy link
Contributor

@dcamper dcamper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@mckellyln
Copy link
Contributor Author

Thanks.
Squashed and rebased to latest candidate-8.12.x.
Ready for merge.

@ghalliday ghalliday merged commit 4c8857f into hpcc-systems:candidate-8.12.x Nov 9, 2023
48 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants