Close - The behavior of Close after the first call returns error for subsequent Close() calls.
()
| 631 | // Close - The behavior of Close after the first call returns error |
| 632 | // for subsequent Close() calls. |
| 633 | func (o *Object) Close() (err error) { |
| 634 | if o == nil { |
| 635 | return errInvalidArgument("Object is nil") |
| 636 | } |
| 637 | |
| 638 | // Locking. |
| 639 | o.mutex.Lock() |
| 640 | defer o.mutex.Unlock() |
| 641 | |
| 642 | // if already closed return an error. |
| 643 | if o.isClosed { |
| 644 | return o.prevErr |
| 645 | } |
| 646 | |
| 647 | // Close successfully. |
| 648 | o.cancel() |
| 649 | |
| 650 | // Close the request channel to indicate the internal go-routine to exit. |
| 651 | close(o.reqCh) |
| 652 | |
| 653 | // Save for future operations. |
| 654 | errMsg := "Object is already closed. Bad file descriptor." |
| 655 | o.prevErr = errors.New(errMsg) |
| 656 | // Save here that we closed done channel successfully. |
| 657 | o.isClosed = true |
| 658 | return nil |
| 659 | } |
| 660 | |
| 661 | // newObject instantiates a new *minio.Object* |
| 662 | // ObjectInfo will be set by setObjectInfo |
no test coverage detected