Skip to content

Commit

Permalink
protect against race conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
djeebus authored and issyl0 committed Oct 6, 2024
1 parent 6a93e6b commit 274c229
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions improvmx/resource_email_forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ func resourceEmailForward() *schema.Resource {

func resourceEmailForwardCreate(d *schema.ResourceData, meta interface{}) error {
m := meta.(*Meta)
m.Mutex.Lock()
defer m.Mutex.Unlock()

m.Client.CreateEmailForward(d.Get("domain").(string), d.Get("alias_name").(string), d.Get("destination_email").(string))

return resourceEmailForwardRead(d, meta)
Expand Down Expand Up @@ -78,6 +81,8 @@ func resourceEmailForwardRead(d *schema.ResourceData, meta interface{}) error {

func resourceEmailForwardUpdate(d *schema.ResourceData, meta interface{}) error {
m := meta.(*Meta)
m.Mutex.Lock()
defer m.Mutex.Unlock()

for {
resp := m.Client.UpdateEmailForward(d.Get("domain").(string), d.Get("alias_name").(string), d.Get("destination_email").(string))
Expand Down

0 comments on commit 274c229

Please sign in to comment.